ZQuest Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2024-05-09 00:53:56
Exec Total Coverage
Lines: 14653 20577 71.2%
Functions: 315 385 81.8%
Branches: 12838 22654 56.7%

Line Branch Exec Source
1 #include <cstring>
2 #include <set>
3 #include <stdio.h>
4
5 #include "base/qrs.h"
6 #include "base/dmap.h"
7 #include "zc/hero.h"
8 #include "zc/guys.h"
9 #include "subscr.h"
10 #include "zc/replay.h"
11 #include "zc/zc_ffc.h"
12 #include "zc/zc_subscr.h"
13 #include "zc/decorations.h"
14 #include "gamedata.h"
15 #include "zc/zc_custom.h"
16 #include "zc/title.h"
17 #include "zc/ffscript.h"
18 #include "drawing.h"
19 #include "zc/combos.h"
20 #include "base/zc_math.h"
21 #include "user_object.h"
22 #include "slopes.h"
23 #include "zinfo.h"
24 #include "base/misctypes.h"
25 #include "music_playback.h"
26 extern FFScript FFCore;
27 extern HeroClass Hero;
28 extern ZModule zcm;
29 extern zcmodule moduledata;
30 extern refInfo playerScriptData;
31 #include "zscriptversion.h"
32 #include "particles.h"
33 #include <fmt/format.h>
34 #include "zc/render.h"
35
36 extern refInfo *ri; //= NULL;
37 extern int32_t(*stack)[MAX_SCRIPT_REGISTERS];
38 extern portal mirror_portal;
39 using std::set;
40
41 extern int32_t skipcont;
42
43 extern int32_t draw_screen_clip_rect_x1;
44 extern int32_t draw_screen_clip_rect_x2;
45 extern int32_t draw_screen_clip_rect_y1;
46 extern int32_t draw_screen_clip_rect_y2;
47
48 int32_t hero_count = -1;
49 int32_t hero_animation_speed = 1; //lower is faster animation
50 static int32_t z3step = 2;
51 351 static zfix hero_newstep(1.5);
52 351 static zfix hero_newstep_diag(1.5);
53 bool did_scripta=false;
54 bool did_scriptb=false;
55 bool did_scriptl=false;
56 byte lshift = 0;
57 int32_t dowpn = -1;
58 int32_t directItemA = -1;
59 int32_t directItemB = -1;
60 int32_t directItemX = -1;
61 int32_t directItemY = -1;
62 int32_t directWpn = -1;
63 int32_t whistleitem=-1;
64 extern int32_t script_hero_cset;
65
66 void playLevelMusic();
67
68 extern particle_list particles;
69
70 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
71
72 #define CANFORCEFACEUP (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
73 #define NO_GRIDLOCK (get_qr(qr_DISABLE_4WAY_GRIDLOCK)||get_qr(qr_NEW_HERO_MOVEMENT2))
74 #define SWITCHBLOCK_STATE (switchblock_z<0?switchblock_z:(switchblock_z+z+fakez < 0 ? zslongToFix(2147483647) : switchblock_z+z+fakez))
75 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_qr(qr_BROKEN_Z3_ANIMATION))
76
77 47 bool item_error()
78 {
79
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 39 times.
47 if(QMisc.miscsfx[sfxERROR])
80 8 sfx(QMisc.miscsfx[sfxERROR]);
81 47 return false;
82 }
83 5350654 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
84 {
85
2/2
✓ Branch 0 taken 1211 times.
✓ Branch 1 taken 5349443 times.
5350654 if(check_new_slope(x, y+0.0001_zf, 16, 16, oldx, oldy, false, true) < 0) return true;
86 5349443 return false;
87 5350654 }
88
89 12092515 static inline bool platform_fallthrough(bool doslopecheck = true)
90 {
91
2/2
✓ Branch 0 taken 10308236 times.
✓ Branch 1 taken 1784279 times.
12092515 if (!getInput(btnDown, false, get_qr(qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
92 10308236 return false;
93
94
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1784279 times.
1784279 if (get_qr(qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
95 return true;
96
97
3/4
✓ Branch 0 taken 26318 times.
✓ Branch 1 taken 1757961 times.
✓ Branch 2 taken 26318 times.
✗ Branch 3 not taken.
1784279 if (Hero.jumping < 0 && get_qr(qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS))
98 return true;
99
100
7/8
✓ Branch 0 taken 1784279 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1056 times.
✓ Branch 3 taken 1783223 times.
✓ Branch 4 taken 1783152 times.
✓ Branch 5 taken 71 times.
✓ Branch 6 taken 155 times.
✓ Branch 7 taken 1784124 times.
3567502 if (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)))
101 155 return true;
102
103 1784124 return false;
104 12092515 }
105
106 4938 static inline bool on_sideview_solid(zfix x, zfix y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
107 {
108
3/4
✓ Branch 0 taken 4938 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3369 times.
✓ Branch 3 taken 1569 times.
4938 if(slopesmisc != 1 && check_slope(x, y + 0.0001_zf, 16, 16, (slopesmisc == 3), true) < 0) return true;
109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3369 times.
3369 if(slopesmisc == 2) return false;
110
3/4
✓ Branch 0 taken 2349 times.
✓ Branch 1 taken 1020 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2349 times.
3369 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
111
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2349 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2349 if (y>=160_zf && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
112
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2349 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2349 if (platform_fallthrough() && !ignoreFallthrough) return false;
113
2/4
✓ Branch 0 taken 2349 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2349 times.
✗ Branch 3 not taken.
2349 if(slopesmisc != 1 && check_slope(x, y + 0.0001_zf, 16, 16, false, true) < 0) return true;
114
4/6
✓ Branch 0 taken 2226 times.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2349 times.
2472 if (y.getInt() % 16 ==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
115 return true;
116 2349 return false;
117 4938 }
118
119 static inline bool on_sideview_solid_oldpos(zfix x, zfix y, zfix oldx, zfix oldy, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
120 {
121 if(slopesmisc != 1 && check_new_slope(x, y+0.0001_zf, 16, 16, oldx, oldy, (slopesmisc == 3), true) < 0) return true;
122 if(slopesmisc == 2) return false;
123 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
124 if (y>=160_zf && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
125 if (platform_fallthrough() && !ignoreFallthrough) return false;
126 if (slopesmisc != 1 && check_new_slope(x, y + 0.0001_zf, 16, 16, oldx, oldy, false, true) < 0) return true;
127 if (y.getInt()%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
128 return true;
129 return false;
130 }
131
132 16086046 static inline bool on_sideview_solid_oldpos(sprite* obj, bool ignoreFallthrough = false, int32_t slopesmisc = 0, zfix xofs = 0, zfix yofs = 0)
133 {
134 16086046 zfix rx = obj->x+obj->hxofs+obj->sxofs+xofs, ry = obj->y+obj->hyofs+obj->syofs+yofs,
135 16086046 rw = obj->hit_width+obj->sxsz_ofs, rh = obj->hit_height+obj->sysz_ofs,
136 16086046 orx = obj->old_x+obj->hxofs+obj->sxofs, ory = obj->old_y+obj->hyofs+obj->syofs,
137 16086046 x = obj->x+xofs, y = obj->y+yofs;
138
4/4
✓ Branch 0 taken 1664886 times.
✓ Branch 1 taken 14421160 times.
✓ Branch 2 taken 1644840 times.
✓ Branch 3 taken 20046 times.
16086046 if(slopesmisc != 1 && check_new_slope(rx, ry+0.0001_zf, rw, rh, orx, ory, (slopesmisc == 3), true, obj->slopeid) < 0) return true;
139
2/2
✓ Branch 0 taken 126943 times.
✓ Branch 1 taken 15939057 times.
16066000 if(slopesmisc == 2) return false;
140
4/4
✓ Branch 0 taken 12419151 times.
✓ Branch 1 taken 3519906 times.
✓ Branch 2 taken 328087 times.
✓ Branch 3 taken 12091064 times.
15939057 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
141
6/6
✓ Branch 0 taken 100818 times.
✓ Branch 1 taken 11990246 times.
✓ Branch 2 taken 6083 times.
✓ Branch 3 taken 94735 times.
✓ Branch 4 taken 5185 times.
✓ Branch 5 taken 898 times.
12091064 if (y>=160_zf && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
142
3/4
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 12090011 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 155 times.
12090166 if (platform_fallthrough() && !ignoreFallthrough) return false;
143
3/4
✓ Branch 0 taken 703733 times.
✓ Branch 1 taken 11386278 times.
✓ Branch 2 taken 703733 times.
✗ Branch 3 not taken.
12090011 if (slopesmisc != 1 && check_new_slope(rx, ry+0.0001_zf, rw, rh, orx, ory, false, true, obj->slopeid) < 0) return true;
144
4/6
✓ Branch 0 taken 9019606 times.
✓ Branch 1 taken 3070405 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3070405 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12090011 times.
15160416 if (y.getInt()%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
145 return true;
146 12090011 return false;
147 16086046 }
148
149 107769 static inline bool no_plat_action()
150 {
151
5/8
✓ Branch 0 taken 107769 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107471 times.
✓ Branch 3 taken 298 times.
✓ Branch 4 taken 107471 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 107471 times.
107769 if(Hero.fallclk || Hero.drownclk || toogam || Hero.getOnSideviewLadder())
152 298 return true;
153
2/2
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 107030 times.
107471 switch(Hero.action)
154 {
155 case freeze: case rafting: case inwind: case scrolling: case won: case hopping:
156 case climbcovertop: case climbcoverbottom: case dying: case drowning:
157 case falling: case lavadrowning: case sideswimfreeze: case sidedrowning:
158 441 return true;
159 }
160 107030 return false;
161 107769 }
162 89687 bool HeroClass::on_ffc_platform(ffcdata const& ffc, bool old)
163 {
164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89687 times.
89687 if(no_plat_action())
165 return false;
166
2/2
✓ Branch 0 taken 49841 times.
✓ Branch 1 taken 39846 times.
89687 if(!get_qr(qr_MULTI_PLATFORM_FFC))
167 {
168
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39846 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39846 if(platform_ffc && &ffc != platform_ffc)
169 return false;
170 39846 platform_ffc = nullptr;
171 39846 }
172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89687 times.
89687 if(sideview_mode())
173 {
174 if((ffc.flags & (ffSOLID|ffPLATFORM|ffCHANGER)) != (ffSOLID|ffPLATFORM))
175 return false;
176 zfix fx = old ? ffc.old_x : ffc.x, fy = old ? ffc.old_y : ffc.y;
177 static const zfix tol = 0.5_zf;
178 if((y+16-fy).getAbs() > tol)
179 return false;
180 if(fx > x+12)
181 return false;
182 if(fx+ffc.hit_width <= x+4)
183 return false;
184 }
185 else
186 {
187
2/2
✓ Branch 0 taken 89498 times.
✓ Branch 1 taken 189 times.
89687 if((ffc.flags & (ffPLATFORM|ffCHANGER)) != ffPLATFORM)
188 89498 return false;
189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(z)
190 return false;
191 static const int tol = 3;
192
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 188 times.
189 if(!(old
193 189 ? ffc.collide_old(x + 8-tol, y + (bigHitbox ? 8 : 12), tol*2, tol*2)
194 : ffc.collide(x + 8-tol, y + (bigHitbox ? 8 : 12)-tol, tol*2, tol*2)))
195 188 return false;
196 }
197 1 platform_ffc = &ffc;
198 1 return true;
199 89687 }
200 18082 bool HeroClass::on_ffc_platform()
201 {
202
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 17343 times.
18082 if(no_plat_action())
203 739 return false;
204
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17343 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17343 if(platform_ffc && on_ffc_platform(*platform_ffc,false))
205 return true;
206 17343 word c = tmpscr->numFFC();
207
2/2
✓ Branch 0 taken 89498 times.
✓ Branch 1 taken 17343 times.
106841 for(word i=0; i<c; i++)
208 {
209 89498 ffcdata& ffc = tmpscr->ffcs[i];
210
1/2
✓ Branch 0 taken 89498 times.
✗ Branch 1 not taken.
89498 if(on_ffc_platform(ffc,false))
211 return true;
212 89498 }
213 17343 return false;
214 18082 }
215
216 14613296 void HeroClass::check_platform_ffc()
217 {
218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14613296 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14613296 if(platform_ffc && !on_ffc_platform(*platform_ffc,false))
219 {
220 clear_platform_ffc();
221 on_ffc_platform();
222 }
223 14613296 }
224 36759 void HeroClass::clear_platform_ffc()
225 {
226 36759 platform_ffc = nullptr;
227 36759 }
228
229 2583 void HeroClass::snap_platform()
230 {
231
2/2
✓ Branch 0 taken 1515 times.
✓ Branch 1 taken 1068 times.
2583 if(check_new_slope(x, y+1, 16, 16, old_x, old_y, false, true) < 0)
232 1515 return;
233
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1068 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1068 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN))
234 {
235 y = 160;
236 return;
237 }
238
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1035 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 18 times.
1068 if (!(_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)))
239 18 return;
240 1050 movexy(0,1,false,true,false,false);
241 2583 }
242
243
244 40751370 bool usingActiveShield(int32_t itmid)
245 {
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40751370 times.
40751370 if(Hero.shieldjinxclk) return false;
247
2/2
✓ Branch 0 taken 5578946 times.
✓ Branch 1 taken 35172424 times.
40751370 switch(Hero.action) //filter allowed actions
248 {
249 case none: case walking: case rafting:
250 case gothit: case swimhit:
251 35172424 break;
252 5578946 default: return false;
253 }
254
4/4
✓ Branch 0 taken 14023 times.
✓ Branch 1 taken 35158401 times.
✓ Branch 2 taken 6009 times.
✓ Branch 3 taken 8014 times.
35172424 if(Hero.lift_wpn && (Hero.liftflags&LIFTFL_DIS_SHIELD)) return false;
255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35164410 times.
35164410 if(itmid < 0)
256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35164410 times.
35164410 itmid = (Hero.active_shield_id < 0
257 35164410 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
258
2/2
✓ Branch 0 taken 31023655 times.
✓ Branch 1 taken 4140755 times.
35164410 if(itmid < 0) return false;
259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31023655 times.
31023655 if(item_disabled(itmid)) return false;
260
1/2
✓ Branch 0 taken 31023655 times.
✗ Branch 1 not taken.
31023655 if(!checkitem_jinx(itmid)) return false;
261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31023655 times.
31023655 if(!(itemsbuf[itmid].flags & ITEM_FLAG9)) return false;
262 if(!isItmPressed(itmid)) return false;
263 return (checkbunny(itmid) && checkmagiccost(itmid));
264 40751370 }
265 4389552 int32_t getCurrentShield(bool requireActive)
266 {
267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4389552 times.
4389552 if(Hero.shieldjinxclk) return -1;
268
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4389552 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4389552 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
269 return Hero.active_shield_id;
270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4389552 times.
4389552 if(!requireActive) return current_item_id(itype_shield);
271 return -1;
272 4389552 }
273 588330 int32_t getCurrentActiveShield()
274 {
275 588330 int32_t id = Hero.active_shield_id;
276
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 588330 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
588330 if(id > -1 && usingActiveShield(id))
277 return id;
278 588330 return -1;
279 588330 }
280 14162652 int32_t refreshActiveShield()
281 {
282 14162652 int32_t id = -1;
283
2/2
✓ Branch 0 taken 13871372 times.
✓ Branch 1 taken 291280 times.
14162652 if(DrunkcBbtn())
284 {
285
2/2
✓ Branch 0 taken 289369 times.
✓ Branch 1 taken 1911 times.
291280 itemdata const& dat = itemsbuf[NEG_OR_MASK(Bwpn,0xFFF)];
286
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 291280 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
291280 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
287 {
288 id = NEG_OR_MASK(Bwpn,0xFFF);
289 }
290 291280 }
291
3/4
✓ Branch 0 taken 14162652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12934260 times.
✓ Branch 3 taken 1228392 times.
14162652 if(id < 0 && DrunkcAbtn())
292 {
293
2/2
✓ Branch 0 taken 1091844 times.
✓ Branch 1 taken 136548 times.
1228392 itemdata const& dat = itemsbuf[NEG_OR_MASK(Awpn,0xFFF)];
294
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1228392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1228392 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
295 {
296 id = NEG_OR_MASK(Awpn,0xFFF);
297 }
298 1228392 }
299
3/4
✓ Branch 0 taken 14162652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14150095 times.
✓ Branch 3 taken 12557 times.
14162652 if(id < 0 && DrunkcEx1btn())
300 {
301
2/2
✓ Branch 0 taken 1997 times.
✓ Branch 1 taken 10560 times.
12557 itemdata const& dat = itemsbuf[NEG_OR_MASK(Xwpn,0xFFF)];
302
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12557 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12557 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
303 {
304 id = NEG_OR_MASK(Xwpn,0xFFF);
305 }
306 12557 }
307
3/4
✓ Branch 0 taken 14162652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14159945 times.
✓ Branch 3 taken 2707 times.
14162652 if(id < 0 && DrunkcEx2btn())
308 {
309
2/2
✓ Branch 0 taken 2471 times.
✓ Branch 1 taken 236 times.
2707 itemdata const& dat = itemsbuf[NEG_OR_MASK(Ywpn,0xFFF)];
310
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2707 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
311 {
312 id = NEG_OR_MASK(Ywpn,0xFFF);
313 }
314 2707 }
315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14162652 times.
14162652 if(!usingActiveShield(id))
316 14162652 return -1;
317 return id;
318 14162652 }
319 static bool is_immobile()
320 {
321 if(!get_qr(qr_NEW_HERO_MOVEMENT))
322 return false;
323 zfix rate(Hero.steprate);
324 int32_t shieldid = getCurrentActiveShield();
325 if(shieldid > -1)
326 {
327 itemdata const& shield = itemsbuf[shieldid];
328 if(shield.flags & ITEM_FLAG10) //Change Speed flag
329 {
330 zfix perc = shield.misc7;
331 perc /= 100;
332 if(perc < 0)
333 perc = (perc*-1)+1;
334 rate = (rate * perc) + shield.misc8;
335 }
336 }
337 return rate != 0;
338 }
339
340 28505199 bool nomove_action(int action)
341 {
342
2/2
✓ Branch 0 taken 27300445 times.
✓ Branch 1 taken 1204754 times.
28505199 switch(action)
343 {
344 case gothit:
345 case drowning:
346 case lavadrowning:
347 case sidedrowning:
348 case falling:
349 case freeze:
350 case sideswimfreeze:
351 case scrolling:
352 case casting:
353 case sideswimcasting:
354 case landhold1:
355 case landhold2:
356 case waterhold1:
357 case waterhold2:
358 case sidewaterhold1:
359 case sidewaterhold2:
360 case hopping:
361 case inwind:
362 1204754 return true;
363 }
364 27300445 return false;
365 28505199 }
366
367 14503282 bool HeroClass::isStanding(bool forJump)
368 {
369
3/4
✓ Branch 0 taken 14471358 times.
✓ Branch 1 taken 31924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14471358 times.
14503282 if(z || fakez) return false;
370
3/4
✓ Branch 0 taken 262509 times.
✓ Branch 1 taken 14208849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 129192 times.
14600550 if(isSideViewHero() && !on_sideview_solid_oldpos(this)
371
4/6
✓ Branch 0 taken 129192 times.
✓ Branch 1 taken 133317 times.
✓ Branch 2 taken 129192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129192 times.
✗ Branch 5 not taken.
262509 && !ladderx && !laddery && !getOnSideviewLadder())
372 129192 return false;
373
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 14342130 times.
14342166 if(hoverclk) return false;
374
2/2
✓ Branch 0 taken 600016 times.
✓ Branch 1 taken 13742114 times.
14342130 if(nomove_action(action)) return false;
375 13742114 int32_t val = check_pitslide();
376
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 13742077 times.
13742114 if(val == -2) return false;
377
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 13741792 times.
13742077 if(val == -1) return true;
378 285 return forJump;
379 14503282 }
380 823822 bool HeroClass::isLifting()
381 {
382
2/2
✓ Branch 0 taken 11972 times.
✓ Branch 1 taken 811850 times.
823822 if(lift_wpn) return true;
383 811850 return false;
384 823822 }
385 68 void HeroClass::set_liftflags(int liftid)
386 {
387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(unsigned(liftid) >= MAXITEMS)
388 return;
389 68 itemdata const& itm = itemsbuf[liftid];
390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 SETFLAG(liftflags, LIFTFL_DIS_SWIMMING, !(itm.flags & ITEM_FLAG2));
391
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 29 times.
68 SETFLAG(liftflags, LIFTFL_DIS_SHIELD, itm.flags & ITEM_FLAG3);
392
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 29 times.
68 SETFLAG(liftflags, LIFTFL_DIS_ITEMS, itm.flags & ITEM_FLAG4);
393 68 }
394
395 523495 void HeroClass::set_respawn_point(bool setwarp)
396 {
397 523495 zfix oldx = x, oldy = y;
398
2/2
✓ Branch 0 taken 34561 times.
✓ Branch 1 taken 488934 times.
523495 if (replay_version_check(17))
399 {
400 488934 x = vbound(x,0_zf,240_zf);
401 488934 y = vbound(y,0_zf,160_zf);
402 488934 }
403
404
2/2
✓ Branch 0 taken 505571 times.
✓ Branch 1 taken 17924 times.
523495 if(setwarp)
405 {
406 17924 warpx = x;
407 17924 warpy = y;
408 17924 raftwarpx = x;
409 17924 raftwarpy = y;
410 17924 }
411 523495 do
412 {
413
2/2
✓ Branch 0 taken 44172 times.
✓ Branch 1 taken 479323 times.
523495 if(!get_qr(qr_OLD_RESPAWN_POINTS))
414 {
415
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 479204 times.
479323 if(currscr >= 0x80) break;
416 479204 bool is_safe = true;
417
2/2
✓ Branch 0 taken 414969 times.
✓ Branch 1 taken 64235 times.
479204 switch(action)
418 {
419 case none: case walking:
420 414969 break;
421 default:
422 64235 is_safe = false;
423 64235 }
424
2/2
✓ Branch 0 taken 414969 times.
✓ Branch 1 taken 64235 times.
479204 if(!is_safe) break; //unsafe action
425
5/6
✓ Branch 0 taken 412089 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 412089 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 412070 times.
414969 if(z > 0 || fakez > 0 || hoverclk) break; //in air
426
4/4
✓ Branch 0 taken 4938 times.
✓ Branch 1 taken 407132 times.
✓ Branch 2 taken 2589 times.
✓ Branch 3 taken 2349 times.
412070 if(sideview_mode() && !on_sideview_solid(x,y,true)) break; //in air sideview
427
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 409568 times.
409721 if(check_pitslide(true) != -1) break; //On a pit
428
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 409557 times.
409568 if (ladderx+laddery) break; //on the ladder
429
430 { //Check water
431 409557 int32_t water = 0;
432 409557 int32_t types[4] = {0};
433 409557 int32_t x1 = x+4, x2 = x+11,
434 409557 y1 = y+9, y2 = y+15;
435
1/2
✓ Branch 0 taken 409557 times.
✗ Branch 1 not taken.
409557 if (get_qr(qr_SMARTER_WATER))
436 {
437
4/4
✓ Branch 0 taken 1905 times.
✓ Branch 1 taken 407652 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 249 times.
409819 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
438
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 748 times.
1905 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
439
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 895 times.
1157 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
440 262 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
441 409557 }
442 else
443 {
444 types[0] = COMBOTYPE(x1,y1);
445
446 if(MAPFFCOMBO(x1,y1))
447 types[0] = FFCOMBOTYPE(x1,y1);
448
449 types[1] = COMBOTYPE(x1,y2);
450
451 if(MAPFFCOMBO(x1,y2))
452 types[1] = FFCOMBOTYPE(x1,y2);
453
454 types[2] = COMBOTYPE(x2,y1);
455
456 if(MAPFFCOMBO(x2,y1))
457 types[2] = FFCOMBOTYPE(x2,y1);
458
459 types[3] = COMBOTYPE(x2,y2);
460
461 if(MAPFFCOMBO(x2,y2))
462 types[3] = FFCOMBOTYPE(x2,y2);
463
464 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
465 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
466 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
467
468 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
469 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
470 water = typec;
471 }
472
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 409308 times.
409557 if(water > 0)
473 249 break;
474 } //End check water
475
476 2046540 int poses[4] = {
477 409308 COMBOPOS(x,y+(bigHitbox?0:8)),
478 409308 COMBOPOS(x,y+15),
479 409308 COMBOPOS(x+15,y+(bigHitbox?0:8)),
480 409308 COMBOPOS(x+15,y+15)
481 };
482
2/2
✓ Branch 0 taken 366168 times.
✓ Branch 1 taken 1516731 times.
1882899 for(auto pos : poses)
483 {
484
2/2
✓ Branch 0 taken 1473591 times.
✓ Branch 1 taken 43140 times.
1516731 if(HASFLAG_ANY(mfUNSAFEGROUND, pos)) //"Unsafe Ground" flag touching the player
485 {
486 43140 is_safe = false;
487 43140 break;
488 }
489 }
490
2/2
✓ Branch 0 taken 366168 times.
✓ Branch 1 taken 43140 times.
409308 if(!is_safe) break;
491 366168 }
492 410340 respawn_x = x;
493 410340 respawn_y = y;
494 410340 respawn_scr = currscr;
495 410340 respawn_dmap = currdmap;
496 410340 }
497 while(false); //run once, but 'break' works
498
499 523495 x = oldx;
500 523495 y = oldy;
501 523495 }
502
503 355700 void HeroClass::clear_ice()
504 {
505 355700 ice_vx = ice_vy = 0;
506 355700 ice_entry_count = ice_entry_mcount = 0;
507 355700 ice_combo = 0;
508 355700 sliding = 0;
509 355700 }
510
511 147 void HeroClass::go_respawn_point()
512 {
513 147 x = respawn_x;
514 147 y = respawn_y;
515 147 clear_ice();
516 147 handle_portal_prox(&mirror_portal);
517
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 portals.forEach([&](sprite& p)
518 {
519 handle_portal_prox((portal*)&p);
520 return false;
521 });
522 147 warpx=x;
523 147 warpy=y;
524 147 raftwarpx = x;
525 147 raftwarpy = y;
526 147 trySideviewLadder(); //Cling to ladder automatically
527
528
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 68 times.
147 if(get_qr(qr_OLD_RESPAWN_POINTS))
529 68 return; //No cross-screen return
530
531
2/4
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79 times.
79 if(currdmap != respawn_dmap || currscr != respawn_scr)
532 {
533 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr-DMaps[currdmap].xoff,
534 -1, -1, 0, 0, warpFlagNOSTEPFORWARD, -1);
535 }
536 147 }
537
538 33325 void HeroClass::trySideviewLadder()
539 {
540
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33325 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33325 if(canSideviewLadder() && !on_sideview_solid_oldpos(this))
541 setOnSideviewLadder(true);
542 33325 }
543
544 65710430 bool HeroClass::can_pitfall(bool ignore_hover)
545 {
546 65710430 return !(
547 65710430 isSideViewGravity()
548
2/2
✓ Branch 0 taken 65107350 times.
✓ Branch 1 taken 603080 times.
65710430 || action==rafting
549
7/8
✓ Branch 0 taken 64767465 times.
✓ Branch 1 taken 339885 times.
✓ Branch 2 taken 64729936 times.
✓ Branch 3 taken 37529 times.
✓ Branch 4 taken 64729936 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64728765 times.
✓ Branch 7 taken 1171 times.
65107350 || z>0 || fakez>0 || fall<0 || fakefall<0
550
3/4
✓ Branch 0 taken 64728765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 64728695 times.
64728765 || (hoverclk && !ignore_hover)
551
6/6
✓ Branch 0 taken 64698513 times.
✓ Branch 1 taken 30252 times.
✓ Branch 2 taken 64694526 times.
✓ Branch 3 taken 3987 times.
✓ Branch 4 taken 64659698 times.
✓ Branch 5 taken 34828 times.
64728765 || inlikelike || inwallm || pull_hero || toogam
552
6/6
✓ Branch 0 taken 64573166 times.
✓ Branch 1 taken 86532 times.
✓ Branch 2 taken 63935233 times.
✓ Branch 3 taken 637933 times.
✓ Branch 4 taken 63934953 times.
✓ Branch 5 taken 280 times.
64659698 || (ladderx||laddery) || getOnSideviewLadder()
553
3/4
✓ Branch 0 taken 63934953 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63922591 times.
✓ Branch 3 taken 12362 times.
63934953 || drownclk || !(moveflags & FLAG_CAN_PITFALL)
554
2/2
✓ Branch 0 taken 743 times.
✓ Branch 1 taken 63921848 times.
63922591 || platform_ffc);
555 }
556
557 8338914 int32_t HeroClass::DrunkClock()
558 {
559 8338914 return drunkclk;
560 }
561 1 void HeroClass::setDrunkClock(int32_t newdrunkclk)
562 {
563 1 drunkclk=newdrunkclk;
564 1 }
565
566 440770 int32_t HeroClass::StunClock()
567 {
568 440770 return lstunclock;
569 }
570 290 void HeroClass::setStunClock(int32_t v)
571 {
572 290 lstunclock=v;
573 290 }
574
575 3104317460 int32_t HeroClass::BunnyClock()
576 {
577 3104317460 return lbunnyclock;
578 }
579 void HeroClass::setBunnyClock(int32_t v)
580 {
581 lbunnyclock=v;
582 }
583
584
13/26
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 351 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 351 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 351 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 351 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 351 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 351 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 351 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 351 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 351 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 351 times.
✗ Branch 25 not taken.
702 HeroClass::HeroClass() : sprite()
585 351 {
586 351 lift_wpn = nullptr;
587
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 init();
588 351 }
589
590 //2.6
591
592 //Stop the subscreen from falling. -Z
593
594 1368 bool HeroClass::stopSubscreenFalling(){
595 1368 return preventsubscreenfalling;
596 }
597
598 void HeroClass::stopSubscreenFalling(bool v){
599 preventsubscreenfalling = v;
600 }
601
602 14164265 void HeroClass::ClearhitHeroUIDs()
603 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
604 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
605 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
606 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
607 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
608 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
609 //clear it on the next frame, but that had the SAME outcome.
610 //Where and how can I clear a value at the end of every frame, so that:
611 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
612 // 2. FFCs can read it before Waitframe. --same.
613 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
614
2/2
✓ Branch 0 taken 240792505 times.
✓ Branch 1 taken 14164265 times.
254956770 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ )
615 {
616 /*
617 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
618 {
619 //Z_scripterrlog("frame is: %d\n", frame);
620 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
621 lastHitBy[q][0] = 0;
622 }
623 */
624 240792505 lastHitBy[q][0] = 0;
625 240792505 }
626 14164265 }
627
628 76478 void HeroClass::sethitHeroUID(int32_t type, int32_t screen_index)
629 {
630 76478 lastHitBy[type][0] = screen_index;
631 76478 }
632
633 3244 int32_t HeroClass::gethitHeroUID(int32_t type)
634 {
635 3244 return lastHitBy[type][0];
636 }
637
638 void HeroClass::set_defence(int32_t type, int32_t v)
639 {
640 defence[type] = v;
641 }
642
643 int32_t HeroClass::get_defence(int32_t type)
644 {
645 return defence[type];
646 }
647
648
649 //Set Hero;s hurt sfx
650 277115 void HeroClass::setHurtSFX(int32_t sfx)
651 {
652 277115 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
653 277115 }
654 15422 int32_t HeroClass::getHurtSFX()
655 {
656 15422 return QMisc.miscsfx[sfxHURTPLAYER];
657 }
658
659 bool HeroClass::getDiagMove()
660 {
661 return diagonalMovement;
662 }
663 void HeroClass::setDiagMove(bool newdiag)
664 {
665 diagonalMovement=newdiag;
666 }
667 271788 bool HeroClass::getBigHitbox()
668 {
669 271788 return bigHitbox;
670 }
671 1432 void HeroClass::setBigHitbox(bool newbigHitbox)
672 {
673 1432 bigHitbox=newbigHitbox;
674 1432 syofs = bigHitbox?0:8;
675 1432 sysz_ofs = bigHitbox?0:-8;
676 1432 }
677 6371 int32_t HeroClass::getStepRate()
678 {
679 6371 return steprate;
680 }
681 947 void HeroClass::setStepRate(int32_t newrate)
682 {
683 947 steprate = newrate;
684 947 }
685 int32_t HeroClass::getSwimUpRate()
686 {
687 return game->get_sideswim_up();
688 }
689 void HeroClass::setSwimUpRate(int32_t newrate)
690 {
691 game->set_sideswim_up(newrate);
692 }
693 int32_t HeroClass::getSwimSideRate()
694 {
695 return game->get_sideswim_side();
696 }
697 void HeroClass::setSwimSideRate(int32_t newrate)
698 {
699 game->set_sideswim_side(newrate);
700 }
701 int32_t HeroClass::getSwimDownRate()
702 {
703 return game->get_sideswim_down();
704 }
705 void HeroClass::setSwimDownRate(int32_t newrate)
706 {
707 game->set_sideswim_down(newrate);
708 }
709
710
711 //void HeroClass::herostep() { lstep = lstep<(BSZ?27:11) ? lstep+1 : 0; }
712 10406075 void HeroClass::herostep()
713 {
714
2/2
✓ Branch 0 taken 9755475 times.
✓ Branch 1 taken 650600 times.
10406075 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
715 //need to run all global/hero/dmap scripts here?
716 10406075 }
717
718 142451 bool is_moving()
719 {
720
6/6
✓ Branch 0 taken 110147 times.
✓ Branch 1 taken 32304 times.
✓ Branch 2 taken 82023 times.
✓ Branch 3 taken 28124 times.
✓ Branch 4 taken 32573 times.
✓ Branch 5 taken 49450 times.
142451 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
721 }
722
723 // called by ALLOFF()
724 35843 void HeroClass::resetflags(bool all)
725 {
726 35843 refilling=REFILL_NONE;
727 35843 inwallm=false;
728 35843 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
729 35843 usecounts.clear();
730
731
4/4
✓ Branch 0 taken 35762 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 369 times.
✓ Branch 3 taken 35393 times.
35843 if(swordclk>0 || all)
732 {
733 450 swordclk=0;
734 450 verifyAWpn();
735 450 }
736
4/4
✓ Branch 0 taken 35825 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 369 times.
✓ Branch 3 taken 35456 times.
35843 if(itemclk>0 || all)
737 387 itemclk=0;
738
3/4
✓ Branch 0 taken 35843 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 369 times.
✓ Branch 3 taken 35474 times.
35843 if(shieldjinxclk>0 || all)
739 369 shieldjinxclk=0;
740
741
2/2
✓ Branch 0 taken 35474 times.
✓ Branch 1 taken 369 times.
35843 if(all)
742 {
743 369 DivineProtectionShieldClk=0;
744
745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 369 times.
369 if(div_prot_item != -1)
746 {
747 stop_sfx(itemsbuf[div_prot_item].usesound);
748 stop_sfx(itemsbuf[div_prot_item].usesound+1);
749 }
750
751 369 div_prot_item = -1;
752 369 hoverclk=jumping=0;
753 369 hoverflags = 0;
754 369 }
755 35843 damageovertimeclk = 0;
756 35843 newconveyorclk = 0;
757 35843 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
758
2/2
✓ Branch 0 taken 35843 times.
✓ Branch 1 taken 250901 times.
286744 for(auto q = 0; q < 7; ++q)
759 250901 hooked_undercombos[q] = -1;
760 35843 hopclk=0;
761 35843 hopdir=-1;
762 35843 attackclk=0;
763 35843 stomping=false;
764 35843 reset_swordcharge();
765 35843 diveclk=drownclk=drownCombo=0;
766 35843 action=none; FFCore.setHeroAction(none);
767 35843 conveyor_flags=0;
768 35843 magiccastclk=0;
769 35843 magicitem=-1;
770 35843 }
771
772 //Can use this for Hero->Stun. -Z
773 14692 void HeroClass::Freeze()
774 {
775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14692 times.
14692 if (action != inwind)
776 {
777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14692 times.
14692 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
778 14692 else {action=freeze; FFCore.setHeroAction(freeze);}
779 // also cancel Hero's attack
780 14692 attackclk = 0;
781 14692 }
782 14692 }
783 5895 void HeroClass::unfreeze()
784 {
785
4/4
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 4615 times.
✓ Branch 2 taken 1279 times.
✓ Branch 3 taken 1 times.
5895 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
786
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5895 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5895 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
787 5895 }
788
789 192 void HeroClass::Drown(int32_t state)
790 {
791 // Hero should never drown if the ladder is out
792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(ladderx+laddery)
793 return;
794
795 192 drop_liftwpn();
796
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 4 times.
192 switch(state)
797 {
798 case 1:
799 4 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
800 4 attackclk=0;
801 4 attack=wNone;
802 4 attackid=-1;
803 4 reset_swordcharge();
804 4 drownclk=64;
805 4 z=fakez=fall=fakefall=0;
806 4 break;
807
808
809 default:
810 {
811
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
188 if (isSideViewHero() && get_qr(qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
812 188 else {action=drowning; FFCore.setHeroAction(drowning);}
813 188 attackclk=0;
814 188 attack=wNone;
815 188 attackid=-1;
816 188 reset_swordcharge();
817 188 drownclk=64;
818 188 z=fakez=fall=fakefall=0;
819 188 break;
820 }
821 }
822
823 192 }
824
825 4619 void HeroClass::finishedmsg()
826 {
827 //these are to cancel out any keys that Hero may
828 //be pressing so he doesn't attack at the end of
829 //a message if he was scrolling through it quickly.
830 4619 rAbtn();
831 4619 rBbtn();
832 4619 unfreeze();
833
834
3/4
✓ Branch 0 taken 4525 times.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4494 times.
9113 if(action == landhold1 ||
835
2/2
✓ Branch 0 taken 4496 times.
✓ Branch 1 taken 29 times.
4525 action == landhold2 ||
836
2/2
✓ Branch 0 taken 4495 times.
✓ Branch 1 taken 1 times.
4496 action == waterhold1 ||
837
2/2
✓ Branch 0 taken 4494 times.
✓ Branch 1 taken 1 times.
4495 action == waterhold2 ||
838
1/2
✓ Branch 0 taken 4494 times.
✗ Branch 1 not taken.
4494 action == sidewaterhold1 ||
839 4494 action == sidewaterhold2)
840 {
841 125 holdclk = 1;
842 125 }
843 4619 }
844 78 void HeroClass::setEaten(int32_t i)
845 {
846 78 inlikelike=i;
847 78 }
848 70 int32_t HeroClass::getEaten()
849 {
850 70 return inlikelike;
851 }
852 60594129 zfix HeroClass::getX()
853 {
854 60594129 return x;
855 }
856 61018640 zfix HeroClass::getY()
857 {
858 61018640 return y;
859 }
860 89640545 zfix HeroClass::getZ()
861 {
862 89640545 return z;
863 }
864 55180664 zfix HeroClass::getFakeZ()
865 {
866 55180664 return fakez;
867 }
868 641401 zfix HeroClass::getFall()
869 {
870 641401 return fall;
871 }
872 zfix HeroClass::getFakeFall()
873 {
874 return fakefall;
875 }
876 zfix HeroClass::getXOfs()
877 {
878 return xofs;
879 }
880 1344 zfix HeroClass::getYOfs()
881 {
882 1344 return yofs;
883 }
884 void HeroClass::setXOfs(int32_t newxofs)
885 {
886 xofs=newxofs;
887 }
888 void HeroClass::setYOfs(int32_t newyofs)
889 {
890 yofs=newyofs;
891 }
892 int32_t HeroClass::getHXOfs()
893 {
894 return hxofs;
895 }
896 int32_t HeroClass::getHYOfs()
897 {
898 return hyofs;
899 }
900 int32_t HeroClass::getHXSz()
901 {
902 return hit_width;
903 }
904 int32_t HeroClass::getHYSz()
905 {
906 return hit_height;
907 }
908 88064 zfix HeroClass::getClimbCoverX()
909 {
910 88064 return climb_cover_x;
911 }
912 88064 zfix HeroClass::getClimbCoverY()
913 {
914 88064 return climb_cover_y;
915 }
916 int32_t HeroClass::getLadderX()
917 {
918 return ladderx;
919 }
920 int32_t HeroClass::getLadderY()
921 {
922 return laddery;
923 }
924
925 459863 void HeroClass::setX(int32_t new_x)
926 {
927 459863 zfix dx=new_x-x;
928 459863 justmoved = 2;
929
2/2
✓ Branch 0 taken 459842 times.
✓ Branch 1 taken 21 times.
459863 if(Lwpns.idFirst(wHookshot)>-1)
930 {
931 21 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
932 21 hs_startx+=(int32_t)dx;
933 21 }
934
935
2/2
✓ Branch 0 taken 459842 times.
✓ Branch 1 taken 21 times.
459863 if(Lwpns.idFirst(wHSHandle)>-1)
936 {
937 21 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
938 21 }
939
940
2/2
✓ Branch 0 taken 459854 times.
✓ Branch 1 taken 9 times.
459863 if(chainlinks.Count()>0)
941 {
942
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 9 times.
28 for(int32_t j=0; j<chainlinks.Count(); j++)
943 {
944 19 chainlinks.spr(j)->x+=dx;
945 19 }
946 9 }
947
948 459863 x=new_x;
949
950 // A kludge
951
4/4
✓ Branch 0 taken 3704 times.
✓ Branch 1 taken 456159 times.
✓ Branch 2 taken 2385 times.
✓ Branch 3 taken 1319 times.
459863 if(!diagonalMovement && dir<=down)
952 1319 is_on_conveyor=true;
953 459863 }
954
955 474139 void HeroClass::setY(int32_t new_y)
956 {
957 474139 zfix dy=new_y-y;
958 474139 justmoved = 2;
959
2/2
✓ Branch 0 taken 474130 times.
✓ Branch 1 taken 9 times.
474139 if(Lwpns.idFirst(wHookshot)>-1)
960 {
961 9 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
962 9 hs_starty+=(int32_t)dy;
963 9 }
964
965
2/2
✓ Branch 0 taken 474130 times.
✓ Branch 1 taken 9 times.
474139 if(Lwpns.idFirst(wHSHandle)>-1)
966 {
967 9 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
968 9 }
969
970
1/2
✓ Branch 0 taken 474139 times.
✗ Branch 1 not taken.
474139 if(chainlinks.Count()>0)
971 {
972 for(int32_t j=0; j<chainlinks.Count(); j++)
973 {
974 chainlinks.spr(j)->y+=dy;
975 }
976 }
977
978 474139 y=new_y;
979
980 // A kludge
981
4/4
✓ Branch 0 taken 3704 times.
✓ Branch 1 taken 470435 times.
✓ Branch 2 taken 1319 times.
✓ Branch 3 taken 2385 times.
474139 if(!diagonalMovement && dir>=left)
982 2385 is_on_conveyor=true;
983 474139 }
984
985 4 void HeroClass::setZ(int32_t new_z)
986 {
987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(isSideViewHero())
988 return;
989
990
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(z==0 && new_z > 0)
991 {
992
1/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 switch(action)
993 {
994 case swimming:
995 {
996 diveclk=0;
997 action=walking; FFCore.setHeroAction(walking);
998 break;
999 }
1000
1001 case waterhold1:
1002 {
1003 action=landhold1; FFCore.setHeroAction(landhold1);
1004 break;
1005 }
1006
1007 case waterhold2:
1008 {
1009 action=landhold2; FFCore.setHeroAction(landhold2);
1010 break;
1011 }
1012
1013 default:
1014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(charging) //!DIMITODO: Let Hero jump while charging sword
1015 {
1016 reset_swordcharge();
1017 attackclk=0;
1018 }
1019
1020 4 break;
1021 }
1022 4 }
1023
1024
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 z=(new_z>0 ? new_z : 0);
1025 4 }
1026
1027 void HeroClass::setFakeZ(int32_t new_z)
1028 {
1029 if(isSideViewHero())
1030 return;
1031
1032 if(fakez==0 && new_z > 0)
1033 {
1034 switch(action)
1035 {
1036 case swimming:
1037 {
1038 diveclk=0;
1039 action=walking; FFCore.setHeroAction(walking);
1040 break;
1041 }
1042
1043 case waterhold1:
1044 {
1045 action=landhold1; FFCore.setHeroAction(landhold1);
1046 break;
1047 }
1048
1049 case waterhold2:
1050 {
1051 action=landhold2; FFCore.setHeroAction(landhold2);
1052 break;
1053 }
1054
1055 default:
1056 if(charging) //!DIMITODO: Let Hero jump while charging sword
1057 {
1058 reset_swordcharge();
1059 attackclk=0;
1060 }
1061
1062 break;
1063 }
1064 }
1065
1066 fakez=(new_z>0 ? new_z : 0);
1067 }
1068
1069 23601 void HeroClass::setXfix(zfix new_x)
1070 {
1071 //Z_scripterrlog("setxdbl: %f\n",new_x);
1072 23601 zfix dx=new_x-x;
1073 23601 justmoved = 2;
1074
2/2
✓ Branch 0 taken 23591 times.
✓ Branch 1 taken 10 times.
23601 if(Lwpns.idFirst(wHookshot)>-1)
1075 {
1076 10 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
1077 10 hs_startx+=(int32_t)dx;
1078 10 }
1079
1080
2/2
✓ Branch 0 taken 23591 times.
✓ Branch 1 taken 10 times.
23601 if(Lwpns.idFirst(wHSHandle)>-1)
1081 {
1082 10 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
1083 10 }
1084
1085
2/2
✓ Branch 0 taken 23594 times.
✓ Branch 1 taken 7 times.
23601 if(chainlinks.Count()>0)
1086 {
1087
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 7 times.
22 for(int32_t j=0; j<chainlinks.Count(); j++)
1088 {
1089 15 chainlinks.spr(j)->x+=dx;
1090 15 }
1091 7 }
1092
1093 23601 x=new_x;
1094
1095 // A kludge
1096
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 23600 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
23601 if(!diagonalMovement && dir<=down)
1097 1 is_on_conveyor=true;
1098 23601 }
1099
1100 22827 void HeroClass::setYfix(zfix new_y)
1101 {
1102 22827 zfix dy=new_y-y;
1103 22827 justmoved = 2;
1104
2/2
✓ Branch 0 taken 22787 times.
✓ Branch 1 taken 40 times.
22827 if(Lwpns.idFirst(wHookshot)>-1)
1105 {
1106 40 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
1107 40 hs_starty+=(int32_t)dy;
1108 40 }
1109
1110
2/2
✓ Branch 0 taken 22787 times.
✓ Branch 1 taken 40 times.
22827 if(Lwpns.idFirst(wHSHandle)>-1)
1111 {
1112 40 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
1113 40 }
1114
1115
2/2
✓ Branch 0 taken 22793 times.
✓ Branch 1 taken 34 times.
22827 if(chainlinks.Count()>0)
1116 {
1117
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 34 times.
213 for(int32_t j=0; j<chainlinks.Count(); j++)
1118 {
1119 179 chainlinks.spr(j)->y+=dy;
1120 179 }
1121 34 }
1122
1123 22827 y=new_y;
1124
1125 // A kludge
1126
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 22826 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
22827 if(!diagonalMovement && dir>=left)
1127 is_on_conveyor=true;
1128 22827 }
1129
1130 2775 void HeroClass::setZfix(zfix new_z)
1131 {
1132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2775 times.
2775 if(isSideViewHero())
1133 return;
1134
1135
4/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 2755 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 14 times.
2775 if(z==0 && new_z > 0)
1136 {
1137
1/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 switch(action)
1138 {
1139 case swimming:
1140 {
1141 diveclk=0;
1142 action=walking; FFCore.setHeroAction(walking);
1143 break;
1144 }
1145
1146 case waterhold1:
1147 {
1148 action=landhold1; FFCore.setHeroAction(landhold1);
1149 break;
1150 }
1151
1152 case waterhold2:
1153 {
1154 action=landhold2; FFCore.setHeroAction(landhold2);
1155 break;
1156 }
1157
1158 default:
1159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(charging) //!DIMITODO: Let Hero jump while charging sword
1160 {
1161 reset_swordcharge();
1162 attackclk=0;
1163 }
1164
1165 14 break;
1166 }
1167 14 }
1168
1169
2/2
✓ Branch 0 taken 2768 times.
✓ Branch 1 taken 7 times.
2775 z=(new_z>0 ? new_z : 0_zf);
1170 2775 }
1171
1172 void HeroClass::setFakeZfix(zfix new_z)
1173 {
1174 if(isSideViewHero())
1175 return;
1176
1177 if(fakez==0 && new_z > 0)
1178 {
1179 switch(action)
1180 {
1181 case swimming:
1182 {
1183 diveclk=0;
1184 action=walking; FFCore.setHeroAction(walking);
1185 break;
1186 }
1187
1188 case waterhold1:
1189 {
1190 action=landhold1; FFCore.setHeroAction(landhold1);
1191 break;
1192 }
1193
1194 case waterhold2:
1195 {
1196 action=landhold2; FFCore.setHeroAction(landhold2);
1197 break;
1198 }
1199
1200 default:
1201 if(charging) //!DIMITODO: Let Hero jump while charging sword
1202 {
1203 reset_swordcharge();
1204 attackclk=0;
1205 }
1206
1207 break;
1208 }
1209 }
1210
1211 fakez=(new_z>0 ? new_z : 0_zf);
1212 }
1213
1214 64852 void HeroClass::setFall(zfix new_fall)
1215 {
1216 64852 fall=new_fall;
1217 64852 justmoved = 2;
1218 64852 jumping=-1;
1219 64852 }
1220 void HeroClass::setFakeFall(zfix new_fall)
1221 {
1222 fakefall=new_fall;
1223 jumping=-1;
1224 }
1225 void HeroClass::setClimbCoverX(int32_t new_x)
1226 {
1227 climb_cover_x=new_x;
1228 }
1229 void HeroClass::setClimbCoverY(int32_t new_y)
1230 {
1231 climb_cover_y=new_y;
1232 }
1233 132628 int32_t HeroClass::getLStep()
1234 {
1235 132628 return lstep;
1236 }
1237 5748 int32_t HeroClass::getCharging()
1238 {
1239 5748 return charging;
1240 }
1241 127085 bool HeroClass::isCharged()
1242 {
1243 127085 return spins>0;
1244 }
1245 2 int32_t HeroClass::getAttackClk()
1246 {
1247 2 return attackclk;
1248 }
1249 2 void HeroClass::setAttackClk(int32_t new_clk)
1250 {
1251 2 attackclk=new_clk;
1252 2 }
1253 void HeroClass::setCharging(int32_t new_charging)
1254 {
1255 charging=new_charging;
1256 }
1257 2953312786 int32_t HeroClass::getSwordClk()
1258 {
1259 2953312786 return swordclk;
1260 }
1261 2918195682 int32_t HeroClass::getItemClk()
1262 {
1263 2918195682 return itemclk;
1264 }
1265 716 void HeroClass::setSwordClk(int32_t newclk)
1266 {
1267 716 swordclk=newclk;
1268 716 verifyAWpn();
1269 716 }
1270 5873 void HeroClass::setItemClk(int32_t newclk)
1271 {
1272 5873 itemclk=newclk;
1273 5873 }
1274 // TODO remove, no longer needed.
1275 1250668 zfix HeroClass::getModifiedX()
1276 {
1277 1250668 zfix tempx=x;
1278 1250668 return tempx;
1279 }
1280
1281 1250668 zfix HeroClass::getModifiedY()
1282 {
1283 1250668 zfix tempy=y;
1284 1250668 return tempy;
1285 }
1286
1287 64167 int32_t HeroClass::getDir()
1288 {
1289 64167 return dir;
1290 }
1291 93583 void HeroClass::setDir(int32_t newdir)
1292 {
1293 93583 dir=newdir;
1294 93583 reset_hookshot();
1295 93583 }
1296 441276 int32_t HeroClass::getHitDir()
1297 {
1298 441276 return hitdir;
1299 }
1300 2220 void HeroClass::setHitDir(int32_t newdir)
1301 {
1302 2220 hitdir = newdir;
1303 2220 }
1304 int32_t HeroClass::getClk()
1305 {
1306 return clk;
1307 }
1308 178963 int32_t HeroClass::getPushing()
1309 {
1310 178963 return pushing;
1311 }
1312 15586 void HeroClass::Catch()
1313 {
1314
5/6
✓ Branch 0 taken 15586 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12606 times.
✓ Branch 3 taken 2980 times.
✓ Branch 4 taken 6225 times.
✓ Branch 5 taken 6381 times.
15586 if(!inwallm && (action==none || action==walking))
1315 {
1316 9205 SetAttack();
1317 9205 attackclk=0;
1318 9205 attack=wCatching;
1319 9205 }
1320 15586 }
1321
1322 4363863 bool HeroClass::getClock()
1323 {
1324 4363863 return superman;
1325 }
1326 952 void HeroClass::setClock(bool state)
1327 {
1328 952 superman=state;
1329 952 }
1330 16545021 int32_t HeroClass::getFlashingCSet()
1331 {
1332 16545021 int32_t temp_cs = 6;
1333
2/2
✓ Branch 0 taken 16292133 times.
✓ Branch 1 taken 252888 times.
16545021 if (script_hero_cset > -1) temp_cs = script_hero_cset;
1334
2/2
✓ Branch 0 taken 2277803 times.
✓ Branch 1 taken 14267218 times.
16545021 if (!get_qr(qr_HEROFLICKER))
1335 {
1336
3/4
✓ Branch 0 taken 120557 times.
✓ Branch 1 taken 14146661 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120557 times.
14267218 if (superman && getCanFlicker())
1337 {
1338 120557 temp_cs += (((~frame) >> 1) & 3);
1339 120557 }
1340
4/6
✓ Branch 0 taken 628810 times.
✓ Branch 1 taken 13517851 times.
✓ Branch 2 taken 628810 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 628810 times.
14146661 else if (hclk && (DivineProtectionShieldClk <= 0) && getCanFlicker())
1341 {
1342 628810 temp_cs += ((hclk >> 1) & 3);
1343 628810 }
1344 14267218 }
1345 16545021 return temp_cs;
1346 }
1347 17462276 bool HeroClass::is_hitflickerframe()
1348 {
1349
6/6
✓ Branch 0 taken 2428528 times.
✓ Branch 1 taken 15033748 times.
✓ Branch 2 taken 2365727 times.
✓ Branch 3 taken 62801 times.
✓ Branch 4 taken 107237 times.
✓ Branch 5 taken 2258490 times.
17462276 if (!(get_qr(qr_HEROFLICKER) && (superman || hclk)))
1350 17292238 return false;
1351
1352 170038 int32_t fr = game->get_spriteflickerspeed();
1353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170038 times.
170038 if (fr == 0)
1354 return true;
1355 170038 return frame % (fr * 2) >= fr;
1356 17462276 }
1357 94327306 int32_t HeroClass::getAction() // Used by ZScript
1358 {
1359
2/2
✓ Branch 0 taken 31122 times.
✓ Branch 1 taken 94296184 times.
94327306 if(spins > 0)
1360 31122 return isspinning;
1361
2/2
✓ Branch 0 taken 369381 times.
✓ Branch 1 taken 93926803 times.
94296184 else if(charging > 0)
1362 369381 return ischarging;
1363
2/2
✓ Branch 0 taken 93819617 times.
✓ Branch 1 taken 107186 times.
93926803 else if(diveclk > 0)
1364 107186 return isdiving;
1365 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1366
1367 93819617 return action;
1368 94327306 }
1369
1370 90047553 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1371 {
1372
2/2
✓ Branch 0 taken 25963 times.
✓ Branch 1 taken 90021590 times.
90047553 if(spins > 0)
1373 25963 return isspinning;
1374
2/2
✓ Branch 0 taken 333968 times.
✓ Branch 1 taken 89687622 times.
90021590 else if(charging > 0)
1375 333968 return ischarging;
1376
2/2
✓ Branch 0 taken 89488673 times.
✓ Branch 1 taken 198949 times.
89687622 else if(diveclk > 0)
1377 198949 return isdiving;
1378 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1379
1380 89488673 return -1;
1381 90047553 }
1382
1383 5057 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1384 {
1385
4/8
✓ Branch 0 taken 5057 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5057 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5057 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5057 times.
10114 if(new_action==dying || new_action==won || new_action==scrolling ||
1386
3/6
✓ Branch 0 taken 5057 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5057 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5057 times.
✗ Branch 5 not taken.
5057 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1387 5057 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1388 return; // Can't use these actions.
1389
1390
3/6
✓ Branch 0 taken 4858 times.
✓ Branch 1 taken 199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4858 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5057 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1391 return;
1392
1393
1/2
✓ Branch 0 taken 5057 times.
✗ Branch 1 not taken.
5057 if(new_action==rafting)
1394 {
1395 if(get_qr(qr_DISALLOW_SETTING_RAFTING)) return;
1396 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1397 return;
1398 }
1399
1400
1401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5057 if(magicitem>-1 && itemsbuf[magicitem].family==itype_divineescape)
1402 {
1403 // Using Divine Escape
1404 if(magiccastclk<96)
1405 {
1406 // Not cast yet; cancel it
1407 magicitem=-1;
1408 magiccastclk=0;
1409 }
1410 else
1411 // Already activated; don't do anything
1412 return;
1413 }
1414
1415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5057 times.
5057 if(action==inwind) // Remove from whirlwind
1416 {
1417 xofs=0;
1418 whirlwind=0;
1419 lstep=0;
1420 if ( dontdraw < 2 ) { dontdraw=0; }
1421 }
1422
2/4
✓ Branch 0 taken 5057 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5057 times.
5057 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1423 {
1424 sprite* wind=0;
1425 bool foundWind=false;
1426 for(int32_t i=0; i<Ewpns.Count(); i++)
1427 {
1428 wind=Ewpns.spr(i);
1429 if(wind->id==ewWind && wind->misc==999)
1430 {
1431 foundWind=true;
1432 break;
1433 }
1434 }
1435
1436 if(foundWind)
1437 {
1438 xofs=0;
1439 if ( dontdraw < 2 ) { dontdraw=false; }
1440 wind->misc=-1;
1441 x=wind->x;
1442 y=wind->y;
1443 }
1444 }
1445
1446 //Unless compat rule is on, reset hopping clocks when writing action!
1447
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5057 if(action == hopping && !get_qr(qr_NO_OVERWRITING_HOPPING))
1448 {
1449 hopclk = 0;
1450 hopdir = -1;
1451 }
1452
1453
3/4
✓ Branch 0 taken 2679 times.
✓ Branch 1 taken 2378 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2679 times.
5057 if(new_action != attacking && new_action != sideswimattacking)
1454 {
1455 2679 attackclk=0;
1456
1457
1/2
✓ Branch 0 taken 2679 times.
✗ Branch 1 not taken.
2679 if(attack==wHookshot)
1458 reset_hookshot();
1459 2679 }
1460
2/4
✓ Branch 0 taken 5057 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5057 times.
5057 if(new_action != isspinning && new_action != sideswimisspinning)
1461 {
1462 5057 charging = 0;
1463 5057 spins = 0;
1464 5057 }
1465
1466
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5057 if(action == falling && new_action != falling)
1467 {
1468 fallclk = 0; //Stop falling;
1469 }
1470
1471
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5057 if (action == rafting && new_action != rafting)
1472 {
1473 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1474 raftwarpy = y;
1475 }
1476
1477
4/9
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2378 times.
✓ Branch 5 taken 2661 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5057 switch(new_action)
1478 {
1479 case isspinning:
1480 case sideswimisspinning:
1481 if(attack==wSword)
1482 {
1483 attackclk = SWORDCHARGEFRAME+1;
1484 charging = 0;
1485
1486 if(spins==0)
1487 spins = 5;
1488 }
1489 return;
1490
1491 case isdiving:
1492 if(action==swimming && diveclk==0)
1493 {
1494 int32_t flippers_id = current_item_id(itype_flippers);
1495 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1496 }
1497 return;
1498
1499 case drowning:
1500 case sidedrowning:
1501 clear_platform_ffc();
1502 if(!drownclk)
1503 Drown();
1504
1505 break;
1506
1507 case lavadrowning:
1508 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1509 clear_platform_ffc();
1510 if(!drownclk)
1511 Drown(1);
1512
1513 break;
1514
1515 case falling:
1516 clear_platform_ffc();
1517 if(!fallclk)
1518 {
1519 //If there is a pit under Hero, use its combo.
1520 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1521 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1522 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1523 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1524 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1525 //Else, use a null value; triggers default pit values
1526 else fallCombo = 0;
1527 fallclk = PITFALL_FALL_FRAMES;
1528 }
1529 break;
1530
1531 case gothit:
1532 case swimhit:
1533 case sideswimhit:
1534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!hclk)
1535 1 hclk=48;
1536
1537 1 break;
1538
1539 case landhold1:
1540 case landhold2:
1541 case waterhold1:
1542 case waterhold2:
1543 case sidewaterhold1:
1544 case sidewaterhold2:
1545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!holdclk)
1546 17 holdclk=130;
1547
1548 17 attack=none;
1549 17 break;
1550
1551 case attacking:
1552 case sideswimattacking:
1553 2378 attack=none;
1554 2378 break;
1555
1556 default:
1557 2661 break;
1558 }
1559
1560 5057 action=new_action; FFCore.setHeroAction(new_action);
1561 5057 }
1562
1563 48 void HeroClass::setHeldItem(int32_t newitem)
1564 {
1565 48 holditem=newitem;
1566 48 }
1567 200 int32_t HeroClass::getHeldItem()
1568 {
1569 200 return holditem;
1570 }
1571 20348413 bool HeroClass::isDiving()
1572 {
1573 20348413 int32_t flippers_id = current_item_id(itype_flippers);
1574
2/2
✓ Branch 0 taken 15039587 times.
✓ Branch 1 taken 5308826 times.
20348413 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1575 }
1576 44767487 bool HeroClass::isSwimming()
1577 {
1578 44767487 bool include_swimhit = true;
1579
3/4
✓ Branch 0 taken 44767487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8603264 times.
✓ Branch 3 taken 36164223 times.
44767487 if (replay_is_active() && replay_version_check(0, 31))
1580 {
1581
2/4
✓ Branch 0 taken 36164223 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36164223 times.
36164223 std::string qst = replay_get_meta_str("qst");
1582 36164223 bool disable = false;
1583
1/2
✓ Branch 0 taken 36164223 times.
✗ Branch 1 not taken.
36164223 disable |= qst == "demons_inferno.qst";
1584
1/2
✓ Branch 0 taken 36164223 times.
✗ Branch 1 not taken.
36164223 disable |= qst == "demosp253.qst";
1585
1/2
✓ Branch 0 taken 36164223 times.
✗ Branch 1 not taken.
36164223 disable |= qst == "hell_awaits.qst";
1586
1/2
✓ Branch 0 taken 36164223 times.
✗ Branch 1 not taken.
36164223 disable |= qst == "lands_of_serenity.qst";
1587
1/2
✓ Branch 0 taken 36164223 times.
✗ Branch 1 not taken.
36164223 disable |= qst == "link_to_the_heavens.qst";
1588 // The others are just a gfx change, but this one actual breaks without this compat check.
1589
1/2
✓ Branch 0 taken 36164223 times.
✗ Branch 1 not taken.
36164223 disable |= qst == "link_to_the_zelda.qst";
1590 36164223 include_swimhit = !disable;
1591 36164223 }
1592
4/6
✓ Branch 0 taken 44316283 times.
✓ Branch 1 taken 451204 times.
✓ Branch 2 taken 44316283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44316283 times.
✗ Branch 5 not taken.
89083770 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1593
8/8
✓ Branch 0 taken 44312270 times.
✓ Branch 1 taken 4013 times.
✓ Branch 2 taken 44309511 times.
✓ Branch 3 taken 2759 times.
✓ Branch 4 taken 27827954 times.
✓ Branch 5 taken 16481557 times.
✓ Branch 6 taken 1166 times.
✓ Branch 7 taken 27826788 times.
44316283 (action==waterhold1)||(action==waterhold2)||(include_swimhit && action==swimhit)||
1594 44308345 (hopclk==0xFF));
1595 }
1596
1597 3275 void HeroClass::setDontDraw(byte new_dontdraw)
1598 {
1599 3275 dontdraw=new_dontdraw;
1600 3275 }
1601
1602 1950427 byte HeroClass::getDontDraw()
1603 {
1604 1950427 return dontdraw;
1605 }
1606
1607 3 void HeroClass::setHClk(int32_t newhclk)
1608 {
1609 3 hclk=newhclk;
1610 3 }
1611
1612 56468 int32_t HeroClass::getHClk()
1613 {
1614 56468 return hclk;
1615 }
1616
1617 11236365 int32_t HeroClass::getSpecialCave()
1618 {
1619 11236365 return specialcave; // used only by maps.cpp
1620 }
1621
1622 1432 void HeroClass::init()
1623 {
1624 1432 cache_tile_mod_clear();
1625 1432 usecounts.clear();
1626 1432 scale = 0;
1627 1432 rotation = 0;
1628 1432 do_animation = true;
1629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1432 times.
1432 if(lift_wpn)
1630 {
1631 delete lift_wpn;
1632 lift_wpn = nullptr;
1633 }
1634 1432 clear_platform_ffc();
1635 1432 liftclk = 0;
1636 1432 tliftclk = 0;
1637 1432 liftheight = 0;
1638 1432 liftflags = 0;
1639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1432 times.
1432 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1640 1432 hookshot_used=false;
1641 1432 justmoved = 0;
1642 1432 hookshot_frozen=false;
1643 1432 onpassivedmg=false;
1644 1432 dir = up;
1645 1432 damageovertimeclk = 0;
1646 1432 newconveyorclk = 0;
1647 1432 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1648
2/2
✓ Branch 0 taken 10024 times.
✓ Branch 1 taken 1432 times.
11456 for(auto q = 0; q < 7; ++q)
1649 10024 hooked_undercombos[q] = -1;
1650 1432 shiftdir = -1;
1651 1432 sideswimdir = right;
1652 1432 holddir = -1;
1653 1432 landswim = 0;
1654 1432 sdir = up;
1655 1432 ilswim=true;
1656 1432 walkable=false;
1657 1432 moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL | FLAG_CAN_WATERDROWN;
1658 1432 warp_sound = 0;
1659 1432 subscr_speed = zinit.subscrSpeed;
1660 1432 steprate = zinit.heroStep;
1661 1432 shove_offset = zinit.shove_offset;
1662 1432 is_warping = false;
1663 1432 coyotetime = 0;
1664
1665 1432 hammer_swim_up_offset = hammeroffsets[0];
1666 1432 hammer_swim_down_offset = hammeroffsets[1];
1667 1432 hammer_swim_left_offset = hammeroffsets[2];
1668 1432 hammer_swim_right_offset = hammeroffsets[3];
1669
1670 1432 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1671
1672
2/2
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 891 times.
1432 if(get_qr(qr_NOARRIVALPOINT))
1673 {
1674 541 x=tmpscr->warpreturnx[0];
1675 541 y=tmpscr->warpreturny[0];
1676 541 }
1677 else
1678 {
1679 891 x=tmpscr->warparrivalx;
1680 891 y=tmpscr->warparrivaly;
1681 }
1682
1683 1432 z=fakez=fall=fakefall=0;
1684 1432 hzsz = 12; // So that flying peahats can still hit him.
1685
1686
2/2
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 984 times.
1432 if(x==0) dir=right;
1687
1688
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1414 times.
1432 if(x==240) dir=left;
1689
1690
2/2
✓ Branch 0 taken 449 times.
✓ Branch 1 taken 983 times.
1432 if(y==0) dir=down;
1691
1692
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 1131 times.
1432 if(y==160) dir=up;
1693
1694 1432 lstep=0;
1695 1432 skipstep=0;
1696 1432 autostep=false;
1697 1432 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1698 1432 attack=wNone;
1699 1432 attackid=-1;
1700 1432 action=none; FFCore.setHeroAction(none); tempaction=none;
1701 1432 xofs=0;
1702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1432 times.
1432 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1703 1432 cs=6;
1704 1432 flickercolor=-1;
1705 1432 flickertransp=-1;
1706 1432 pushing=fairyclk=0;
1707 1432 id=0;
1708 1432 inlikelike=0;
1709 1432 superman=inwallm=false;
1710 1432 scriptcoldet=true;
1711 1432 blowcnt=whirlwind=specialcave=0;
1712 1432 hopclk=diveclk=fallclk=0;
1713 1432 fallCombo = 0;
1714 1432 pit_pulldir = -1;
1715 1432 hopdir=-1;
1716 1432 conveyor_flags=0;
1717 1432 drunkclk=0;
1718 1432 lstunclock = 0;
1719 1432 is_conveyor_stunned=0;
1720 1432 convey_forcex=convey_forcey=0;
1721 1432 drawstyle=3;
1722 1432 ffwarp = false;
1723 1432 stepoutindex=stepoutwr=stepoutdmap=stepoutscr=0;
1724 1432 stepnext=stepsecret=-1;
1725 1432 ffpit = false;
1726 1432 respawn_x=x;
1727 1432 respawn_y=y;
1728 1432 respawn_dmap=currdmap;
1729 1432 respawn_scr=currscr;
1730 1432 falling_oldy = y;
1731 1432 magiccastclk=0;
1732 1432 magicitem = div_prot_item = -1;
1733 1432 last_lens_id = 0; //Should be -1 (-Z)
1734 1432 last_lift_id.reset();
1735 1432 last_savepoint_id = 0;
1736 1432 misc_internal_hero_flags = 0;
1737 1432 last_cane_of_byrna_item_id = -1;
1738 1432 on_sideview_ladder = false;
1739 1432 switchblock_z = 0;
1740 1432 switchblock_offset = false;
1741 1432 extra_jump_count = 0;
1742 1432 hoverflags = 0;
1743 1432 lbunnyclock = 0;
1744 1432 lamp_paid = false;
1745
1746
2/2
✓ Branch 0 taken 45824 times.
✓ Branch 1 taken 1432 times.
47256 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1747
1748 1432 setBigHitbox(get_qr(qr_LTTPCOLLISION));
1749 1432 diagonalMovement=(get_qr(qr_LTTPWALK));
1750
1751 1432 shield_active = false;
1752 1432 shield_forcedir = -1;
1753 1432 active_shield_id = -1;
1754 1432 conv_forcedir = -1;
1755
1756 1432 preventsubscreenfalling = false; //-Z
1757 1432 walkspeed = 0; //not used, yet. -Z
1758
2/2
✓ Branch 0 taken 24344 times.
✓ Branch 1 taken 1432 times.
25776 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1759
2/2
✓ Branch 0 taken 24344 times.
✓ Branch 1 taken 1432 times.
25776 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1760
2/2
✓ Branch 0 taken 209072 times.
✓ Branch 1 taken 1432 times.
210504 for ( int32_t q = 0; q < wMax; q++ )
1761 {
1762 209072 defence[q] = hero_defence[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1763 //zprint2("defence[%d] is: %d\n", q, defence[q]);
1764 209072 }
1765
1766 1432 clear_ice();
1767 1432 script_ice_combo = 0;
1768 //Run script!
1769
4/4
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 1237 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 105 times.
1432 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1770 {
1771 90 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_INIT);
1772 90 FFCore.deallocateAllScriptOwned(ScriptType::Player, SCRIPT_PLAYER_INIT);
1773 90 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1774 90 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1775 //are properly set by the engine.
1776 90 }
1777 1432 FFCore.nostepforward = 0;
1778
1779
2/2
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 1116 times.
1432 if (replay_version_check(12))
1780 1116 z3step = 2;
1781 1432 }
1782
1783 16567954 void HeroClass::draw_under(BITMAP* dest)
1784 {
1785 16567954 int32_t c_raft=current_item_id(itype_raft);
1786 16567954 int32_t c_ladder=current_item_id(itype_ladder);
1787
1788
3/4
✓ Branch 0 taken 144426 times.
✓ Branch 1 taken 16423528 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144426 times.
16567954 if(action==rafting && c_raft >-1)
1789 {
1790
4/4
✓ Branch 0 taken 106833 times.
✓ Branch 1 taken 37593 times.
✓ Branch 2 taken 82762 times.
✓ Branch 3 taken 61664 times.
144426 if(((dir==left) || (dir==right)) && (get_qr(qr_RLFIX)))
1791 {
1792 123328 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1793 61664 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1794 61664 }
1795 else
1796 {
1797 165524 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1798 82762 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1799 }
1800 144426 }
1801
1802
3/4
✓ Branch 0 taken 142297 times.
✓ Branch 1 taken 16425657 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 142297 times.
16567954 if(ladderx+laddery && c_ladder >-1)
1803 {
1804
4/4
✓ Branch 0 taken 67726 times.
✓ Branch 1 taken 74571 times.
✓ Branch 2 taken 44376 times.
✓ Branch 3 taken 23350 times.
142297 if((ladderdir>=left) && (get_qr(qr_RLFIX)))
1805 {
1806 88752 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1807 44376 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[iRaft].misc_flags>>2)&3)^3);
1808 44376 }
1809 else
1810 {
1811 195842 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1812 97921 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1813 }
1814 142297 }
1815 16567954 }
1816
1817 18783 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1818 {
1819 18783 int32_t tempy=yofs;
1820 18783 yofs+=8;
1821 18783 shadowtile = wpnsbuf[spr_shadow].tile;
1822 18783 sprite::drawshadow(dest,translucent);
1823 18783 yofs=tempy;
1824 18783 }
1825
1826 // The Stone of Agony reacts to these flags.
1827 483872 bool HeroClass::agonyflag(int32_t flag)
1828 {
1829
2/2
✓ Branch 0 taken 483840 times.
✓ Branch 1 taken 32 times.
483872 switch(flag)
1830 {
1831 case mfWHISTLE:
1832 case mfANYFIRE:
1833 case mfARROW:
1834 case mfBOMB:
1835 case mfSBOMB:
1836 case mfBRANG:
1837 case mfMBRANG:
1838 case mfFBRANG:
1839 case mfSARROW:
1840 case mfGARROW:
1841 case mfSTRONGFIRE:
1842 case mfMAGICFIRE:
1843 case mfDIVINEFIRE:
1844 case mfWANDMAGIC:
1845 case mfREFMAGIC:
1846 case mfREFFIREBALL:
1847 case mfSWORD:
1848 case mfWSWORD:
1849 case mfMSWORD:
1850 case mfXSWORD:
1851 case mfSWORDBEAM:
1852 case mfWSWORDBEAM:
1853 case mfMSWORDBEAM:
1854 case mfXSWORDBEAM:
1855 case mfHOOKSHOT:
1856 case mfWAND:
1857 case mfHAMMER:
1858 case mfSTRIKE:
1859 32 return true;
1860 }
1861
1862 483840 return false;
1863 483872 }
1864
1865
1866 // Find the attack power of the current melee weapon.
1867 // The Whimsical Ring is applied on a target-by-target basis.
1868 1103109 int32_t HeroClass::weaponattackpower(int32_t itid)
1869 {
1870
1/2
✓ Branch 0 taken 1103109 times.
✗ Branch 1 not taken.
1103109 if(itid < 0)
1871 {
1872 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1873 : attack==wWand ? itype_wand
1874 : attack==wHammer ? itype_hammer
1875 : itype_sword);
1876 }
1877
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1103089 times.
1103109 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1878
1879 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1880
2/2
✓ Branch 0 taken 2189 times.
✓ Branch 1 taken 1100920 times.
1103109 if(spins > 0)
1881 {
1882 2189 int scr = currentscroll;
1883
1/2
✓ Branch 0 taken 2189 times.
✗ Branch 1 not taken.
2189 if(scr < 0)
1884 {
1885 scr = current_item_id(attack==wHammer ? (spins>1?itype_quakescroll2:itype_quakescroll)
1886 : (spins>5 || current_item_id(itype_spinscroll) < 0)
1887 ? itype_spinscroll2 : itype_spinscroll);
1888 }
1889 2189 power *= itemsbuf[scr].power;
1890 2189 }
1891 1100920 else currentscroll = -1;
1892 1103109 return power;
1893 }
1894
1895 #define NET_CLK_TOTAL 24
1896 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1897 // Must only be called once per frame!
1898 138 void HeroClass::positionNet(weapon *w, int32_t itemid)
1899 {
1900 138 itemid = vbound(itemid, 0, MAXITEMS-1);
1901 138 int32_t t = w->o_tile,
1902 138 wx = 1, wy = 1;
1903
1904 //Invert positioning clock if right-handed animation
1905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 int32_t clock = (itemsbuf[itemid].flags&ITEM_FLAG2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1906
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
138 if(clock >= NET_CLK_TOTAL)
1907 w->dead = 0;
1908 138 int32_t tiledir = dir;
1909
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 69 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 38 times.
138 switch(dir)
1910 {
1911 case up:
1912 {
1913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(clock < NET_DIR_INC) tiledir = l_up;
1914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1915 8 break;
1916 }
1917 case down:
1918 {
1919
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 48 times.
69 if(clock < NET_DIR_INC) tiledir = r_down;
1920
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1921 69 break;
1922 }
1923 case left:
1924 {
1925
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(clock < NET_DIR_INC) tiledir = l_down;
1926
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
1927 23 break;
1928 }
1929 case right:
1930 {
1931
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 24 times.
38 if(clock < NET_DIR_INC) tiledir = r_up;
1932
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
24 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
1933 38 break;
1934 }
1935 }
1936 138 int32_t offs = 0;
1937
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 48 times.
138 if(tiledir > right)
1938 90 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
1939 48 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
1940 //One of 8 positions
1941
7/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 29 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 31 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 8 times.
138 switch(tiledir)
1942 {
1943 case up:
1944 {
1945 wx = 6*offs;
1946 wy = -14;
1947 break;
1948 }
1949 case r_up:
1950 {
1951 22 wx = (offs ? 10 : 14);
1952 22 wy = (offs ? -12 : -10);
1953 22 break;
1954 }
1955 case right:
1956 {
1957 16 wx = 14;
1958 16 wy = 6*offs;
1959 16 break;
1960 }
1961 case r_down:
1962 {
1963 29 wx = (offs ? 14 : 10);
1964 29 wy = (offs ? 10 : 12);
1965 29 break;
1966 }
1967 case down:
1968 {
1969 24 wx = -6*offs;
1970 24 wy = 14;
1971 24 break;
1972 }
1973 case l_down:
1974 {
1975 31 wx = (offs ? -10 : -14);
1976 31 wy = (offs ? 12 : 10);
1977 31 break;
1978 }
1979 case left:
1980 {
1981 8 wx = -14;
1982 8 wy = -6*offs;
1983 8 break;
1984 }
1985 case l_up:
1986 {
1987 8 wx = (offs ? -14 : -10);
1988 8 wy = (offs ? -10 : -12);
1989 8 break;
1990 }
1991 }
1992
1993 138 w->x = x+wx;
1994 138 w->y = y+wy-(54-(yofs))-fakez;
1995 138 w->z = (z+zofs);
1996 138 w->fakez = fakez;
1997 138 w->tile = t+tiledir;
1998 138 w->power = 0;
1999 138 w->dir = dir;
2000 138 w->doAutoRotate(true);
2001 138 }
2002 964220 void HeroClass::positionSword(weapon *w, int32_t itemid)
2003 {
2004 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
2005 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2006 964220 itemid=vbound(itemid, 0, MAXITEMS-1);
2007 // Place a sword weapon at the right spot.
2008 964220 int32_t wy=1;
2009 964220 int32_t wx=1;
2010 964220 int32_t f=0,t,cs2;
2011
2012 964220 t = w->o_tile;
2013 964220 cs2 = w->o_cset;
2014 964220 slashxofs=0;
2015 964220 slashyofs=0;
2016
2017
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 197194 times.
✓ Branch 2 taken 208186 times.
✓ Branch 3 taken 278611 times.
✓ Branch 4 taken 280229 times.
964220 switch(dir)
2018 {
2019 case up:
2020 197194 wx=-1;
2021 197194 wy=-12;
2022
2023
8/8
✓ Branch 0 taken 88038 times.
✓ Branch 1 taken 109156 times.
✓ Branch 2 taken 86461 times.
✓ Branch 3 taken 1577 times.
✓ Branch 4 taken 86051 times.
✓ Branch 5 taken 410 times.
✓ Branch 6 taken 8142 times.
✓ Branch 7 taken 77909 times.
197194 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
2024 {
2025
2/2
✓ Branch 0 taken 49930 times.
✓ Branch 1 taken 27979 times.
77909 if(attackclk>10) //extended stab
2026 {
2027 27979 slashyofs-=3;
2028 27979 wy-=2;
2029 27979 }
2030
2031
2/2
✓ Branch 0 taken 69527 times.
✓ Branch 1 taken 8382 times.
77909 if(attackclk>=14) //retracting stab
2032 {
2033 8382 slashyofs+=3;
2034 8382 wy+=2;
2035 8382 }
2036 77909 }
2037 else
2038 {
2039
2/2
✓ Branch 0 taken 6746 times.
✓ Branch 1 taken 112539 times.
119285 if(attackclk==SWORDCHARGEFRAME)
2040 {
2041 6746 wy+=4;
2042 6746 }
2043
2/2
✓ Branch 0 taken 10909 times.
✓ Branch 1 taken 101630 times.
112539 else if(attackclk==13)
2044 {
2045 10909 wy+=4;
2046 10909 }
2047
2/2
✓ Branch 0 taken 90829 times.
✓ Branch 1 taken 10801 times.
101630 else if(attackclk==14)
2048 {
2049 10801 wy+=8;
2050 10801 }
2051 }
2052
2053 197194 break;
2054
2055 case down:
2056 208186 f=get_qr(qr_SWORDWANDFLIPFIX)?3:2;
2057 208186 wy=11;
2058
2059
8/8
✓ Branch 0 taken 111342 times.
✓ Branch 1 taken 96844 times.
✓ Branch 2 taken 109939 times.
✓ Branch 3 taken 1403 times.
✓ Branch 4 taken 109579 times.
✓ Branch 5 taken 360 times.
✓ Branch 6 taken 6988 times.
✓ Branch 7 taken 102591 times.
208186 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
2060 {
2061
2/2
✓ Branch 0 taken 64549 times.
✓ Branch 1 taken 38042 times.
102591 if(attackclk>10) //extended stab
2062 {
2063 38042 slashyofs+=3;
2064 38042 wy+=2;
2065 38042 }
2066
2067
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 11534 times.
102591 if(attackclk>=14) //retracting stab
2068 {
2069 11534 slashyofs-=3;
2070 11534 wy-=2;
2071 11534 }
2072 102591 }
2073 else
2074 {
2075
2/2
✓ Branch 0 taken 6473 times.
✓ Branch 1 taken 99122 times.
105595 if(attackclk==SWORDCHARGEFRAME)
2076 {
2077 6473 wy-=2;
2078 6473 }
2079
2/2
✓ Branch 0 taken 9870 times.
✓ Branch 1 taken 89252 times.
99122 else if(attackclk==13)
2080 {
2081 9870 wy-=4;
2082 9870 }
2083
2/2
✓ Branch 0 taken 79417 times.
✓ Branch 1 taken 9835 times.
89252 else if(attackclk==14)
2084 {
2085 9835 wy-=8;
2086 9835 }
2087 }
2088
2089 208186 break;
2090
2091 case left:
2092 278611 f=1;
2093 278611 wx=-11;
2094 278611 ++t;
2095
2096
8/8
✓ Branch 0 taken 157227 times.
✓ Branch 1 taken 121384 times.
✓ Branch 2 taken 153528 times.
✓ Branch 3 taken 3699 times.
✓ Branch 4 taken 152676 times.
✓ Branch 5 taken 852 times.
✓ Branch 6 taken 10065 times.
✓ Branch 7 taken 142611 times.
278611 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
2097 {
2098
2/2
✓ Branch 0 taken 88770 times.
✓ Branch 1 taken 53841 times.
142611 if(attackclk>10) //extended stab
2099 {
2100 53841 slashxofs-=4;
2101 53841 wx-=7;
2102 53841 }
2103
2104
2/2
✓ Branch 0 taken 126778 times.
✓ Branch 1 taken 15833 times.
142611 if(attackclk>=14) //retracting stab
2105 {
2106 15833 slashxofs+=3;
2107 15833 wx+=7;
2108 15833 }
2109 142611 }
2110 else
2111 {
2112
2/2
✓ Branch 0 taken 8752 times.
✓ Branch 1 taken 127248 times.
136000 if(attackclk==SWORDCHARGEFRAME)
2113 {
2114 8752 wx+=2;
2115 8752 }
2116
2/2
✓ Branch 0 taken 12652 times.
✓ Branch 1 taken 114596 times.
127248 else if(attackclk==13)
2117 {
2118 12652 wx+=4;
2119 12652 }
2120
2/2
✓ Branch 0 taken 101987 times.
✓ Branch 1 taken 12609 times.
114596 else if(attackclk==14)
2121 {
2122 12609 wx+=8;
2123 12609 }
2124 }
2125
2126 278611 break;
2127
2128 case right:
2129 280229 wx=11;
2130 280229 ++t;
2131
2132
8/8
✓ Branch 0 taken 152576 times.
✓ Branch 1 taken 127653 times.
✓ Branch 2 taken 149774 times.
✓ Branch 3 taken 2802 times.
✓ Branch 4 taken 147940 times.
✓ Branch 5 taken 1834 times.
✓ Branch 6 taken 134274 times.
✓ Branch 7 taken 13666 times.
280229 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
2133 {
2134
2/2
✓ Branch 0 taken 83205 times.
✓ Branch 1 taken 51069 times.
134274 if(attackclk>10) //extended stab
2135 {
2136 51069 slashxofs+=4;
2137 51069 wx+=7;
2138 51069 }
2139
2140
2/2
✓ Branch 0 taken 118695 times.
✓ Branch 1 taken 15579 times.
134274 if(attackclk>=14) //retracting stab
2141 {
2142 15579 slashxofs-=3;
2143 15579 wx-=7;
2144 15579 }
2145 134274 }
2146 else
2147 {
2148
2/2
✓ Branch 0 taken 12322 times.
✓ Branch 1 taken 133633 times.
145955 if(attackclk==SWORDCHARGEFRAME)
2149 {
2150 12322 wx-=2;
2151 12322 }
2152
2/2
✓ Branch 0 taken 13266 times.
✓ Branch 1 taken 120367 times.
133633 else if(attackclk==13)
2153 {
2154 13266 wx-=4;
2155 13266 }
2156
2/2
✓ Branch 0 taken 107139 times.
✓ Branch 1 taken 13228 times.
120367 else if(attackclk==14)
2157 {
2158 13228 wx-=8;
2159 13228 }
2160 }
2161
2162 280229 break;
2163 }
2164
2165
6/6
✓ Branch 0 taken 509183 times.
✓ Branch 1 taken 455037 times.
✓ Branch 2 taken 499032 times.
✓ Branch 3 taken 10151 times.
✓ Branch 4 taken 210781 times.
✓ Branch 5 taken 288251 times.
964220 if(game->get_canslash() && itemsbuf[itemid].flags & ITEM_FLAG4 && attackclk<11)
2166 {
2167 288251 int32_t wpn2=itemsbuf[itemid].wpn2;
2168 288251 wpn2=vbound(wpn2, 0, MAXWPNS);
2169
2170 //slashing tiles
2171
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 50215 times.
✓ Branch 2 taken 64943 times.
✓ Branch 3 taken 89403 times.
✓ Branch 4 taken 83690 times.
288251 switch(dir)
2172 {
2173 case up:
2174 50215 wx=15;
2175 50215 wy=-3;
2176 50215 ++t;
2177 50215 f=0; //starts pointing right
2178
2179
2/2
✓ Branch 0 taken 22396 times.
✓ Branch 1 taken 27819 times.
50215 if(attackclk>=7)
2180 {
2181 27819 wy-=9;
2182 27819 wx-=3;
2183 27819 t = wpnsbuf[wpn2].tile;
2184 27819 cs2 = wpnsbuf[wpn2].csets&15;
2185 27819 f=0;
2186 27819 }
2187
2188 50215 break;
2189
2190 case down:
2191 64943 wx=-13;
2192 64943 wy=-1;
2193 64943 ++t;
2194 64943 f=1; //starts pointing left
2195
2196
2/2
✓ Branch 0 taken 28352 times.
✓ Branch 1 taken 36591 times.
64943 if(attackclk>=7)
2197 {
2198 36591 wy+=15;
2199 36591 wx+=2;
2200 36591 t = wpnsbuf[wpn2].tile;
2201 36591 cs2 = wpnsbuf[wpn2].csets&15;
2202 36591 ++t;
2203 36591 f=0;
2204 36591 }
2205
2206 64943 break;
2207
2208 case left:
2209 89403 wx=3;
2210 89403 wy=-15;
2211 89403 --t;
2212 89403 f=0; //starts pointing up
2213
2214
2/2
✓ Branch 0 taken 38120 times.
✓ Branch 1 taken 51283 times.
89403 if(attackclk>=7)
2215 {
2216 51283 wx-=15;
2217 51283 wy+=3;
2218 51283 slashxofs-=1;
2219 51283 t = wpnsbuf[wpn2].tile;
2220 51283 cs2 = wpnsbuf[wpn2].csets&15;
2221 51283 t+=2;
2222 51283 f=0;
2223 51283 }
2224
2225 89403 break;
2226
2227 case right:
2228 83690 --t;
2229
2230
3/4
✓ Branch 0 taken 83277 times.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83277 times.
83690 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2231 {
2232 413 wx=1;
2233 413 wy=13;
2234 413 f=2;
2235 413 }
2236 else
2237 {
2238 83277 wx=3;
2239 83277 wy=-15;
2240 83277 f=0;
2241 }
2242
2243
2/2
✓ Branch 0 taken 35729 times.
✓ Branch 1 taken 47961 times.
83690 if(attackclk>=7)
2244 {
2245 47961 wx+=15;
2246 47961 slashxofs+=1;
2247 47961 t = wpnsbuf[wpn2].tile;
2248 47961 cs2 = wpnsbuf[wpn2].csets&15;
2249
2250
3/4
✓ Branch 0 taken 47686 times.
✓ Branch 1 taken 275 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47686 times.
47961 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2251 {
2252 275 wx-=1;
2253 275 wy-=2;
2254 275 }
2255 else
2256 {
2257 47686 t+=3;
2258 47686 f=0;
2259 47686 wy+=3;
2260 }
2261 47961 }
2262
2263 83690 break;
2264 }
2265 288251 }
2266
2267 964220 int32_t itemid2 = current_item_id(itype_chargering);
2268
2269
4/4
✓ Branch 0 taken 27595 times.
✓ Branch 1 taken 936625 times.
✓ Branch 2 taken 951099 times.
✓ Branch 3 taken 13121 times.
964220 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2270 {
2271
2/2
✓ Branch 0 taken 12589 times.
✓ Branch 1 taken 532 times.
13121 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2272 13121 }
2273
2274 /*if(BSZ || ((isdungeon() && currscr<128) && !get_qr(qr_HERODUNGEONPOSFIX)))
2275 {
2276 wy+=2;
2277 }*/
2278 964220 w->x = x+wx;
2279 964220 w->y = y+wy-(54-(yofs+slashyofs))-fakez;
2280 964220 w->z = (z+zofs);
2281 964220 w->tile = t;
2282 964220 w->flip = f;
2283 964220 w->power = weaponattackpower(itemid);
2284 964220 w->dir = dir;
2285 964220 w->doAutoRotate(true);
2286 964220 }
2287
2288 int HeroClass::getHammerState() const
2289 {
2290 if(attack == wHammer)
2291 {
2292 if(attackclk >= 15)
2293 return 3;
2294 if(attackclk >= 13)
2295 return 2;
2296 return 1;
2297 }
2298 return 0;
2299 }
2300 1093035 weapon* find_first_wtype(int wtype)
2301 {
2302
2/2
✓ Branch 0 taken 1176706 times.
✓ Branch 1 taken 88715 times.
1265421 for(int32_t i=0; i<Lwpns.Count(); i++)
2303 {
2304 1176706 weapon* w = (weapon*)Lwpns.spr(i);
2305
2306
2/2
✓ Branch 0 taken 1004320 times.
✓ Branch 1 taken 172386 times.
1176706 if(w->id == wtype)
2307 1004320 return w;
2308 172386 }
2309 88715 return nullptr;
2310 1093035 }
2311 16696114 void HeroClass::draw(BITMAP* dest)
2312 {
2313 /*{
2314 char buf[36];
2315 //sprintf(buf,"%d %d %d %d %d %d %d",dir, action, attack, attackclk, charging, spins, tapping);
2316 textout_shadowed_ex(framebuf,font, buf, 2,72,WHITE,BLACK,-1);
2317 }*/
2318 16696114 int32_t oxofs = xofs, oyofs = yofs;
2319 16696114 bool shieldModify = false;
2320
2/2
✓ Branch 0 taken 93472 times.
✓ Branch 1 taken 16602642 times.
16696114 bool invisible=(dontdraw>0) || (tmpscr->flags3&fINVISHERO);
2321
2322 {
2323
2/2
✓ Branch 0 taken 16475 times.
✓ Branch 1 taken 16679639 times.
16696114 if(action==dying)
2324 {
2325
2/2
✓ Branch 0 taken 12476 times.
✓ Branch 1 taken 3999 times.
16475 if(!invisible)
2326 {
2327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3999 times.
3999 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2328 3999 sprite::draw(dest);
2329 3999 }
2330 16475 goto herodraw_end;
2331 }
2332
2333 16679639 bool useltm=(get_qr(qr_EXPANDEDLTM) != 0);
2334
2335
2336
2/2
✓ Branch 0 taken 268628 times.
✓ Branch 1 taken 16411011 times.
16679639 if(!invisible)
2337
6/6
✓ Branch 0 taken 7401345 times.
✓ Branch 1 taken 9009666 times.
✓ Branch 2 taken 4809154 times.
✓ Branch 3 taken 2592191 times.
✓ Branch 4 taken 183822 times.
✓ Branch 5 taken 4625332 times.
16411011 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2338
2339 // Stone of Agony
2340 16679639 bool agony=false;
2341 16679639 int32_t agonyid = current_item_id(itype_agony);
2342
2343
2/2
✓ Branch 0 taken 268628 times.
✓ Branch 1 taken 16411011 times.
16679639 if(!invisible)
2344 {
2345
2/2
✓ Branch 0 taken 241944 times.
✓ Branch 1 taken 16169067 times.
16411011 if(agonyid>-1)
2346 {
2347 241944 int32_t power=itemsbuf[agonyid].power;
2348 241944 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2349 241944 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2350 241944 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2351 241944 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2352
2353
2/2
✓ Branch 0 taken 241944 times.
✓ Branch 1 taken 241944 times.
483888 for(int32_t x=left; x<right; x+=16)
2354 {
2355
2/2
✓ Branch 0 taken 241912 times.
✓ Branch 1 taken 241944 times.
483856 for(int32_t y=top; y<bottom; y+=16)
2356 {
2357
4/4
✓ Branch 0 taken 241928 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 241912 times.
✓ Branch 3 taken 16 times.
241944 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2358 {
2359 32 agony=true;
2360 32 x=right; // Break out of outer loop
2361 32 break;
2362 }
2363 241912 }
2364 241944 }
2365 241944 }
2366
2367 16411011 cs = getFlashingCSet();
2368 16411011 }
2369
2370
5/6
✓ Branch 0 taken 14948721 times.
✓ Branch 1 taken 1730918 times.
✓ Branch 2 taken 14935504 times.
✓ Branch 3 taken 13217 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14935504 times.
16679639 if(attackclk || (action==attacking||action==sideswimattacking))
2371 {
2372 /* Spaghetti code constants!
2373 * - Hero.attack contains a weapon type...
2374 * - which must be converted to an itype...
2375 * - which must be converted to an item ID...
2376 * - which is used to acquire a wpn ID! Aack!
2377 */
2378
8/8
✓ Branch 0 taken 38498 times.
✓ Branch 1 taken 1705637 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 1705609 times.
✓ Branch 4 taken 25729 times.
✓ Branch 5 taken 1679880 times.
✓ Branch 6 taken 64609 times.
✓ Branch 7 taken 1615271 times.
1744135 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2379
4/4
✓ Branch 0 taken 487431 times.
✓ Branch 1 taken 1196202 times.
✓ Branch 2 taken 324390 times.
✓ Branch 3 taken 163041 times.
1744135 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2380 1683633 itemid=vbound(itemid, 0, MAXITEMS-1);
2381 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2382
8/8
✓ Branch 0 taken 574338 times.
✓ Branch 1 taken 1109295 times.
✓ Branch 2 taken 574314 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 377898 times.
✓ Branch 5 taken 196416 times.
✓ Branch 6 taken 213409 times.
✓ Branch 7 taken 164489 times.
1683633 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2383 {
2384
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1322590 times.
1322728 if(attack == wBugNet)
2385 {
2386 138 weapon *w=NULL;
2387 138 bool found = false;
2388
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 132 times.
138 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2389 {
2390 132 w = (weapon*)Lwpns.spr(q);
2391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(w->id == wBugNet)
2392 {
2393 132 found = true;
2394 132 break;
2395 }
2396 }
2397
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 6 times.
138 if(!found)
2398 {
2399
5/10
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
6 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2400
2401 6 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2402 6 }
2403 138 positionNet(w, itemid);
2404 138 }
2405
8/8
✓ Branch 0 taken 248420 times.
✓ Branch 1 taken 1074170 times.
✓ Branch 2 taken 230046 times.
✓ Branch 3 taken 18374 times.
✓ Branch 4 taken 215307 times.
✓ Branch 5 taken 14739 times.
✓ Branch 6 taken 229556 times.
✓ Branch 7 taken 1093034 times.
1322590 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2406 {
2407 // Create a sword weapon at the right spot.
2408 1093034 weapon *w=find_first_wtype(attack==wSword ? wSword : wWand);
2409
2/2
✓ Branch 0 taken 1004319 times.
✓ Branch 1 taken 88715 times.
1093034 if(!w) // Create one if sword nonexistant
2410 {
2411
5/10
✓ Branch 0 taken 88715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88715 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88715 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88715 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 88715 times.
✗ Branch 9 not taken.
88715 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2412 88715 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2413
2414 88715 positionSword(w,itemid);
2415
2416 // Stone of Agony
2417
1/2
✓ Branch 0 taken 88715 times.
✗ Branch 1 not taken.
88715 if(agony)
2418 {
2419 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2420 }
2421 88715 }
2422
2423 // These are set by positionSword(), above or in checkstab()
2424 1093034 yofs += slashyofs;
2425 1093034 xofs += slashxofs;
2426 1093034 slashyofs = slashxofs = 0;
2427 1093034 }
2428 1322728 }
2429
2430 1683735 if(attackclk<7
2431
4/4
✓ Branch 0 taken 916650 times.
✓ Branch 1 taken 766983 times.
✓ Branch 2 taken 730897 times.
✓ Branch 3 taken 185753 times.
1683633 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2432
4/6
✓ Branch 0 taken 137310 times.
✓ Branch 1 taken 593587 times.
✓ Branch 2 taken 137310 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 137310 times.
730897 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2433
2/2
✓ Branch 0 taken 38044 times.
✓ Branch 1 taken 99266 times.
137310 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2434
4/4
✓ Branch 0 taken 304224 times.
✓ Branch 1 taken 24181 times.
✓ Branch 2 taken 292803 times.
✓ Branch 3 taken 11421 times.
323063 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2435
4/4
✓ Branch 0 taken 29380 times.
✓ Branch 1 taken 299025 times.
✓ Branch 2 taken 50923 times.
✓ Branch 3 taken 248102 times.
328405 || (attack==wHammer && attackclk<=30)
2436
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 248000 times.
299025 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2437 {
2438
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 1478679 times.
1479019 if(!invisible)
2439 {
2440 1478679 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2441
2/4
✓ Branch 0 taken 1478679 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1478679 times.
✗ Branch 3 not taken.
1478679 if (FIXED_Z3_ANIMATION)
2442 {
2443 if (attackclk >= 2) tile += (extend==2?2:1);
2444 if (attackclk >= 13) tile += (extend==2?2:1);
2445 }
2446
2447
14/18
✓ Branch 0 taken 741402 times.
✓ Branch 1 taken 737277 times.
✓ Branch 2 taken 157181 times.
✓ Branch 3 taken 584221 times.
✓ Branch 4 taken 146300 times.
✓ Branch 5 taken 10881 times.
✓ Branch 6 taken 141820 times.
✓ Branch 7 taken 4480 times.
✓ Branch 8 taken 583160 times.
✓ Branch 9 taken 158242 times.
✓ Branch 10 taken 330566 times.
✓ Branch 11 taken 252594 times.
✓ Branch 12 taken 330566 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 330566 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
1478679 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&ITEM_FLAG4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2448 {
2449 252594 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2450
2/4
✓ Branch 0 taken 252594 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 252594 times.
✗ Branch 3 not taken.
252594 if (FIXED_Z3_ANIMATION)
2451 {
2452 if (attackclk >= 7) tile += (extend==2?2:1);
2453 if (attackclk >= 11) tile += (extend==2?2:1);
2454 if (attackclk >= 14) tile += (extend==2?2:1);
2455 }
2456 252594 }
2457
3/4
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1478541 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 138 times.
1478679 if (attack==wBugNet && !get_qr(qr_OLD_BUG_NET))
2458 {
2459
6/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 62 times.
138 if ((dir == right && (itemsbuf[itemid].flags&ITEM_FLAG2)) || (dir != right && !(itemsbuf[itemid].flags&ITEM_FLAG2)))
2460 {
2461
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 32 times.
100 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2462
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 40 times.
100 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2463 100 }
2464 else
2465 {
2466
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 16 times.
162 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2467
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 8 times.
38 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2468 }
2469 138 }
2470
2471
4/4
✓ Branch 0 taken 64609 times.
✓ Branch 1 taken 1414070 times.
✓ Branch 2 taken 37727 times.
✓ Branch 3 taken 26882 times.
1478679 if((attack==wHammer) && (attackclk<13))
2472 {
2473 26882 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2474
2/4
✓ Branch 0 taken 26882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26882 times.
✗ Branch 3 not taken.
26882 if (FIXED_Z3_ANIMATION)
2475 {
2476 if (attackclk >= 14) tile += (extend==2?2:1);
2477 if (attackclk >= 16) tile += (extend==2?2:1);
2478 }
2479 26882 }
2480
2481
2/2
✓ Branch 0 taken 987163 times.
✓ Branch 1 taken 491516 times.
1478679 if(useltm)
2482 {
2483
2/2
✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 489676 times.
491516 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2484 491516 }
2485
2486 // Stone of Agony
2487
1/2
✓ Branch 0 taken 1478679 times.
✗ Branch 1 not taken.
1478679 if(agony)
2488 {
2489 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2490 }
2491
2492 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2493
2494 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2495
2/2
✓ Branch 0 taken 12487 times.
✓ Branch 1 taken 1466192 times.
1478679 if (is_hitflickerframe())
2496 {
2497
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12485 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12485 times.
12487 int32_t temp_flicker_color = (game->get_life() > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
2498
2/4
✓ Branch 0 taken 12487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12487 times.
✗ Branch 3 not taken.
12487 if((game->get_spriteflickercolor() || temp_flicker_color) && !superman)
2499 {
2500 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
2501 sprite_flicker_color = temp_flicker_color;
2502 masked_draw(dest);
2503 }
2504 12487 }
2505 else
2506 1466192 masked_draw(dest);
2507
2508 //Prevent flickering -Z
2509
1/2
✓ Branch 0 taken 1478679 times.
✗ Branch 1 not taken.
1478679 if (!getCanFlicker()) masked_draw(dest);
2510 1478679 }
2511
2512
2/2
✓ Branch 0 taken 1414410 times.
✓ Branch 1 taken 64609 times.
1479019 if(attack!=wHammer)
2513 1414410 goto herodraw_end;
2514 64609 }
2515
2516
2/2
✓ Branch 0 taken 64609 times.
✓ Branch 1 taken 248000 times.
312609 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2517 {
2518 64609 int32_t wy=1;
2519 64609 int32_t wx=1;
2520 64609 int32_t f=0,t,cs2;
2521 64609 weapon *w=NULL;
2522 64609 bool found = false;
2523
2524
2/2
✓ Branch 0 taken 2255 times.
✓ Branch 1 taken 63240 times.
65495 for(int32_t i=0; i<Lwpns.Count(); i++)
2525 {
2526 63240 w = (weapon*)Lwpns.spr(i);
2527
2528
2/2
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 62354 times.
63240 if(w->id == wHammer)
2529 {
2530 62354 found = true;
2531 62354 break;
2532 }
2533 886 }
2534
2535
2/2
✓ Branch 0 taken 62354 times.
✓ Branch 1 taken 2255 times.
64609 if(!found)
2536 {
2537
5/10
✓ Branch 0 taken 2255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2255 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2255 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2255 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2255 times.
✗ Branch 9 not taken.
2255 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2538 2255 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2539 2255 found = true;
2540 2255 }
2541
2542 64609 t = w->o_tile;
2543 64609 cs2 = w->o_cset;
2544
2545
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 10368 times.
✓ Branch 2 taken 15134 times.
✓ Branch 3 taken 21126 times.
✓ Branch 4 taken 17981 times.
64609 switch(dir)
2546 {
2547 case up:
2548 10368 wx=-1;
2549 10368 wy=-15;
2550
1/2
✓ Branch 0 taken 10368 times.
✗ Branch 1 not taken.
10368 if (IsSideSwim())wy+=hammer_swim_up_offset;
2551
2552
2/2
✓ Branch 0 taken 4383 times.
✓ Branch 1 taken 5985 times.
10368 if(attackclk>=13)
2553 {
2554 5985 wx-=1;
2555 5985 wy+=1;
2556 5985 ++t;
2557 5985 }
2558
2559
2/2
✓ Branch 0 taken 5061 times.
✓ Branch 1 taken 5307 times.
10368 if(attackclk>=15)
2560 {
2561
1/2
✓ Branch 0 taken 5307 times.
✗ Branch 1 not taken.
5307 if (IsSideSwim())wy-=hammer_swim_up_offset;
2562 5307 ++t;
2563 5307 }
2564
2565 10368 break;
2566
2567 case down:
2568 15134 wx=3;
2569 15134 wy=-14;
2570
1/2
✓ Branch 0 taken 15134 times.
✗ Branch 1 not taken.
15134 if (IsSideSwim())wy+=hammer_swim_down_offset;
2571 15134 t+=3;
2572
2573
2/2
✓ Branch 0 taken 6339 times.
✓ Branch 1 taken 8795 times.
15134 if(attackclk>=13)
2574 {
2575 8795 wy+=16;
2576 8795 ++t;
2577 8795 }
2578
2579
2/2
✓ Branch 0 taken 7346 times.
✓ Branch 1 taken 7788 times.
15134 if(attackclk>=15)
2580 {
2581 7788 wx-=1;
2582 7788 wy+=12;
2583
1/2
✓ Branch 0 taken 7788 times.
✗ Branch 1 not taken.
7788 if (IsSideSwim())wy-=hammer_swim_down_offset;
2584 7788 ++t;
2585 7788 }
2586
2587 15134 break;
2588
2589 case left:
2590 21126 wx=0;
2591 21126 wy=-14;
2592
1/2
✓ Branch 0 taken 21126 times.
✗ Branch 1 not taken.
21126 if (IsSideSwim())wy+=hammer_swim_left_offset;
2593 21126 t+=6;
2594 21126 f=1;
2595
2596
2/2
✓ Branch 0 taken 8777 times.
✓ Branch 1 taken 12349 times.
21126 if(attackclk>=13)
2597 {
2598 12349 wx-=7;
2599 12349 wy+=8;
2600 12349 ++t;
2601 12349 }
2602
2603
2/2
✓ Branch 0 taken 10191 times.
✓ Branch 1 taken 10935 times.
21126 if(attackclk>=15)
2604 {
2605 10935 wx-=8;
2606 10935 wy+=8;
2607
1/2
✓ Branch 0 taken 10935 times.
✗ Branch 1 not taken.
10935 if (IsSideSwim())wy-=hammer_swim_left_offset;
2608 10935 ++t;
2609 10935 }
2610
2611 21126 break;
2612
2613 case right:
2614 17981 wx=0;
2615 17981 wy=-14;
2616
1/2
✓ Branch 0 taken 17981 times.
✗ Branch 1 not taken.
17981 if (IsSideSwim())wy+=hammer_swim_right_offset;
2617 17981 t+=6;
2618
2619
2/2
✓ Branch 0 taken 7383 times.
✓ Branch 1 taken 10598 times.
17981 if(attackclk>=13)
2620 {
2621 10598 wx+=7;
2622 10598 wy+=8;
2623 10598 ++t;
2624 10598 }
2625
2626
2/2
✓ Branch 0 taken 8581 times.
✓ Branch 1 taken 9400 times.
17981 if(attackclk>=15)
2627 {
2628 9400 wx+=8;
2629 9400 wy+=8;
2630
1/2
✓ Branch 0 taken 9400 times.
✗ Branch 1 not taken.
9400 if (IsSideSwim())wy-=hammer_swim_right_offset;
2631 9400 ++t;
2632 9400 }
2633
2634 17981 break;
2635 }
2636
2637
7/8
✓ Branch 0 taken 28062 times.
✓ Branch 1 taken 36547 times.
✓ Branch 2 taken 20878 times.
✓ Branch 3 taken 7184 times.
✓ Branch 4 taken 20878 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4720 times.
✓ Branch 7 taken 16158 times.
64609 if(BSZ || ((isdungeon() && currscr<128) && !get_qr(qr_HERODUNGEONPOSFIX)))
2638 {
2639 52705 wy+=2;
2640 52705 }
2641
2642 // Stone of Agony
2643
1/2
✓ Branch 0 taken 64609 times.
✗ Branch 1 not taken.
64609 if(agony)
2644 {
2645 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2646 }
2647
2648 64609 w->x = x+wx;
2649 64609 w->y = y+wy-(54-yofs)-fakez;
2650 64609 w->z = (z+zofs);
2651 64609 w->tile = t;
2652 64609 w->flip = f;
2653 64609 w->hit_width=20;
2654 64609 w->hit_height=20;
2655
2656
2/2
✓ Branch 0 taken 39107 times.
✓ Branch 1 taken 25502 times.
64609 if(dir>down)
2657 {
2658 39107 w->hit_height-=6;
2659 39107 }
2660 else
2661 {
2662 25502 w->hit_width-=6;
2663 25502 w->hyofs=4;
2664 }
2665
2666 64609 w->power = weaponattackpower(itemid);
2667
2668
7/10
✓ Branch 0 taken 2130 times.
✓ Branch 1 taken 62479 times.
✓ Branch 2 taken 2130 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2130 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 2125 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
64609 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2669 {
2670
3/4
✓ Branch 0 taken 2118 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2130 times.
✗ Branch 3 not taken.
2130 sfx(((iswaterex(MAPCOMBO(x+wx+8,y+wy), currmap, currscr, -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_qr(qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2671 2130 }
2672
2673 64609 goto herodraw_end;
2674 }
2675 248000 }
2676
2/4
✓ Branch 0 taken 14935504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14935504 times.
14935504 else if(!charging && !spins) // remove the sword
2677 {
2678
2/2
✓ Branch 0 taken 2937032 times.
✓ Branch 1 taken 14935504 times.
17872536 for(int32_t i=0; i<Lwpns.Count(); i++)
2679 {
2680 2937032 weapon *w = (weapon*)Lwpns.spr(i);
2681
2682
6/6
✓ Branch 0 taken 2936235 times.
✓ Branch 1 taken 797 times.
✓ Branch 2 taken 2934727 times.
✓ Branch 3 taken 1508 times.
✓ Branch 4 taken 31846 times.
✓ Branch 5 taken 2902881 times.
2937032 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2683 34151 w->dead=1;
2684 2937032 }
2685 14935504 }
2686
2687
2/2
✓ Branch 0 taken 251172 times.
✓ Branch 1 taken 14932332 times.
15183504 if(invisible)
2688 {
2689 251172 goto herodraw_end;
2690 }
2691
2692
3/4
✓ Branch 0 taken 14929485 times.
✓ Branch 1 taken 2847 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14929485 times.
14932332 if(action != casting && action != sideswimcasting)
2693 {
2694 // Keep this consistent with checkspecial2, line 7800-ish...
2695
6/6
✓ Branch 0 taken 295963 times.
✓ Branch 1 taken 14633522 times.
✓ Branch 2 taken 285086 times.
✓ Branch 3 taken 10877 times.
✓ Branch 4 taken 12379 times.
✓ Branch 5 taken 272707 times.
14929485 bool inwater = iswaterex(MAPCOMBO(x+4,y+9), currmap, currscr, -1, x+4, y+9, true, false) && iswaterex(MAPCOMBO(x+4,y+15), currmap, currscr, -1, x+4, y+15, true, false) && iswaterex(MAPCOMBO(x+11,y+9), currmap, currscr, -1, x+11, y+9, true, false) && iswaterex(MAPCOMBO(x+11,y+15), currmap, currscr, -1, x+11, y+15, true, false);
2696
2697 14929485 int32_t jumping2 = int32_t(jumping*((zinit.gravity / 100)/16.0));
2698 14929485 bool noliftspr = get_qr(qr_NO_LIFT_SPRITE);
2699 14929485 bool advancetile = script_hero_sprite <= 0;
2700 //if (jumping!=0) al_trace("%d %d %f %d\n",jumping,zinit.gravity,zinit.gravity/16.0,jumping2);
2701
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8436703 times.
✓ Branch 3 taken 6492782 times.
14929485 switch(zinit.heroAnimationStyle)
2702 {
2703 case las_original: //normal
2704
2/2
✓ Branch 0 taken 3040 times.
✓ Branch 1 taken 8433663 times.
8436703 if(action==drowning)
2705 {
2706
1/2
✓ Branch 0 taken 3040 times.
✗ Branch 1 not taken.
3040 if(inwater)
2707 {
2708 3040 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3040 times.
3040 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2710 3040 }
2711 else
2712 {
2713 goto herodraw_end;
2714 }
2715 3040 }
2716
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 8433407 times.
8433663 else if(action==lavadrowning)
2717 {
2718 256 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
256 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2720 256 }
2721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8433407 times.
8433407 else if(action==sidedrowning)
2722 {
2723 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2724 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2725 }
2726
2/4
✓ Branch 0 taken 8433407 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8433407 times.
8433407 else if (action == sideswimming || action == sideswimhit)
2727 {
2728 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2729
2730 if(lstep>=6)
2731 {
2732 if(dir==up)
2733 {
2734 if(advancetile) ++flip;
2735 }
2736 else
2737 {
2738 if(advancetile) extend==2?tile+=2:++tile;
2739 }
2740 }
2741 }
2742
5/6
✓ Branch 0 taken 8338770 times.
✓ Branch 1 taken 94637 times.
✓ Branch 2 taken 8337949 times.
✓ Branch 3 taken 821 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8337949 times.
8433407 else if(action==swimming || action==swimhit || hopclk==0xFF)
2743 {
2744 95458 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2745
2746
2/2
✓ Branch 0 taken 47669 times.
✓ Branch 1 taken 47789 times.
95458 if(lstep>=6)
2747 {
2748
2/2
✓ Branch 0 taken 9775 times.
✓ Branch 1 taken 38014 times.
47789 if(dir==up)
2749 {
2750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9775 times.
9775 if(advancetile) ++flip;
2751 9775 }
2752 else
2753 {
2754
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38014 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38014 times.
38014 if(advancetile) extend==2?tile+=2:++tile;
2755 }
2756 47789 }
2757
2758
2/2
✓ Branch 0 taken 90255 times.
✓ Branch 1 taken 5203 times.
95458 if(isDiving())
2759 {
2760 5203 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5203 times.
5203 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2762 5203 }
2763 95458 }
2764
3/4
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 8336331 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618 times.
8337949 else if(charging > 0 && attack != wHammer)
2765 {
2766 1618 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2767
2768
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 675 times.
1618 if(lstep>=6)
2769 {
2770
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 144 times.
675 if(dir==up)
2771 {
2772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(advancetile) ++flip;
2773 144 }
2774 else
2775 {
2776
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 531 times.
531 if(advancetile) extend==2?tile+=2:++tile;
2777 }
2778 675 }
2779 1618 }
2780
9/12
✓ Branch 0 taken 8336089 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 8336089 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 85805 times.
✓ Branch 5 taken 8250526 times.
✓ Branch 6 taken 71761 times.
✓ Branch 7 taken 14044 times.
✓ Branch 8 taken 71761 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 71761 times.
8336331 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2781 {
2782 71761 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71761 times.
71761 if(advancetile) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2784 71761 }
2785
2/2
✓ Branch 0 taken 1890 times.
✓ Branch 1 taken 8262680 times.
8264570 else if(fallclk>0)
2786 {
2787 1890 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1890 times.
1890 if(advancetile) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2789 1890 }
2790
5/6
✓ Branch 0 taken 419450 times.
✓ Branch 1 taken 7843230 times.
✓ Branch 2 taken 585 times.
✓ Branch 3 taken 418865 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 585 times.
8262680 else if(!noliftspr&&action==lifting&&isLifting())
2791 {
2792 585 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
585 if(script_hero_sprite <= 0)
2794 {
2795 585 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2796 585 auto speed = tliftclk/frames;
2797
1/2
✓ Branch 0 taken 585 times.
✗ Branch 1 not taken.
585 if (speed < 1) speed = 1;
2798 585 auto curframe = (tliftclk - liftclk) / speed;
2799
1/2
✓ Branch 0 taken 585 times.
✗ Branch 1 not taken.
585 if (!tliftclk) curframe = frames - 1;
2800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
585 if(unsigned(curframe) < frames)
2801 585 tile += curframe * (extend == 2 ? 2 : 1);
2802 585 }
2803 585 }
2804 else
2805 {
2806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8262095 times.
8262095 if(IsSideSwim())
2807 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2808 else
2809 {
2810
4/4
✓ Branch 0 taken 418865 times.
✓ Branch 1 taken 7843230 times.
✓ Branch 2 taken 410269 times.
✓ Branch 3 taken 8596 times.
8262095 if(!noliftspr&&isLifting())
2811 8596 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2812 8253499 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2813 }
2814
2815
2/2
✓ Branch 0 taken 6128485 times.
✓ Branch 1 taken 2133610 times.
8262095 if(dir>up)
2816 {
2817 6128485 useltm=true;
2818 6128485 shieldModify=true;
2819 6128485 }
2820
2821
3/4
✓ Branch 0 taken 8262095 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4023710 times.
✓ Branch 3 taken 4238385 times.
8262095 if(advancetile && lstep>=6)
2822 {
2823
2/2
✓ Branch 0 taken 1085885 times.
✓ Branch 1 taken 3152500 times.
4238385 if(dir==up)
2824 {
2825 1085885 ++flip;
2826 1085885 }
2827 else
2828 {
2829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3152500 times.
3152500 extend==2?tile+=2:++tile;
2830 }
2831 4238385 }
2832 }
2833
2834 8436703 break;
2835
2836 case las_bszelda: //BS
2837
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 6489838 times.
6492782 if(action==drowning)
2838 {
2839
1/2
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
2944 if(inwater)
2840 {
2841 2944 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2944 times.
2944 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2843 2944 }
2844 else
2845 {
2846 goto herodraw_end;
2847 }
2848 2944 }
2849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6489838 times.
6489838 else if (action == sidedrowning)
2850 {
2851 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2852 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2853 }
2854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6489838 times.
6489838 else if(action==lavadrowning)
2855 {
2856 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2857 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2858 }
2859
2/4
✓ Branch 0 taken 6489838 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6489838 times.
6489838 else if (action == sideswimming || action == sideswimhit)
2860 {
2861 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2862
2863 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2864 }
2865
6/6
✓ Branch 0 taken 6428194 times.
✓ Branch 1 taken 61644 times.
✓ Branch 2 taken 6427763 times.
✓ Branch 3 taken 431 times.
✓ Branch 4 taken 157 times.
✓ Branch 5 taken 6427606 times.
6489838 else if(action==swimming || action==swimhit || hopclk==0xFF)
2866 {
2867
2/2
✓ Branch 0 taken 15239 times.
✓ Branch 1 taken 46993 times.
62232 if (get_qr(qr_COPIED_SWIM_SPRITES))
2868 {
2869 15239 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2870 15239 }
2871 else
2872 {
2873 46993 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2874 }
2875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62232 times.
62232 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2876
2877
2/2
✓ Branch 0 taken 56358 times.
✓ Branch 1 taken 5874 times.
62232 if(isDiving())
2878 {
2879
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 5034 times.
5874 if (get_qr(qr_COPIED_SWIM_SPRITES))
2880 {
2881 840 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2882 840 }
2883 else
2884 {
2885 5034 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2886 }
2887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5874 times.
5874 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2888 5874 }
2889 62232 }
2890
3/4
✓ Branch 0 taken 32285 times.
✓ Branch 1 taken 6395321 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32285 times.
6427606 else if(charging > 0 && attack != wHammer)
2891 {
2892 32285 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32285 times.
32285 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2894 32285 }
2895
8/10
✓ Branch 0 taken 6376276 times.
✓ Branch 1 taken 19045 times.
✓ Branch 2 taken 6376276 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18002 times.
✓ Branch 5 taken 6377319 times.
✓ Branch 6 taken 11530 times.
✓ Branch 7 taken 6472 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 11530 times.
6395321 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2896 {
2897 11530 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2898
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 11461 times.
11530 if(advancetile) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2899 11530 }
2900
2/2
✓ Branch 0 taken 1890 times.
✓ Branch 1 taken 6381901 times.
6383791 else if(fallclk>0)
2901 {
2902 1890 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1890 times.
1890 if(advancetile) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2904 1890 }
2905
5/6
✓ Branch 0 taken 404372 times.
✓ Branch 1 taken 5977529 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 403993 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
6381901 else if(!noliftspr&&action==lifting&&isLifting())
2906 {
2907 379 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 379 times.
379 if(script_hero_sprite <= 0)
2909 {
2910 379 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2911 379 auto speed = tliftclk/frames;
2912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 379 times.
379 if (speed < 1) speed = 1;
2913 379 auto curframe = (tliftclk - liftclk) / speed;
2914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 379 times.
379 if (!tliftclk) curframe = frames - 1;
2915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 379 times.
379 if(unsigned(curframe) < frames)
2916 379 tile += curframe * (extend == 2 ? 2 : 1);
2917 379 }
2918 379 }
2919 else
2920 {
2921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6381522 times.
6381522 if(IsSideSwim())
2922 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2923 else
2924 {
2925
4/4
✓ Branch 0 taken 403993 times.
✓ Branch 1 taken 5977529 times.
✓ Branch 2 taken 401581 times.
✓ Branch 3 taken 2412 times.
6381522 if(!noliftspr&&isLifting())
2926 2412 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2927 6379110 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2928 }
2929
2930
2/2
✓ Branch 0 taken 1824846 times.
✓ Branch 1 taken 4556676 times.
6381522 if(dir > up)
2931 {
2932 4556676 useltm=true;
2933 4556676 shieldModify=true;
2934 4556676 }
2935
2/2
✓ Branch 0 taken 6489 times.
✓ Branch 1 taken 6375033 times.
6381522 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2936 }
2937
2938 6492782 break;
2939
2940 case las_zelda3slow: //8-frame Zelda 3 (slow)
2941 case las_zelda3: //8-frame Zelda 3
2942 if(action == drowning)
2943 {
2944 if(inwater)
2945 {
2946 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2947 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2948 }
2949 else
2950 {
2951 goto herodraw_end;
2952 }
2953 }
2954 else if(action == lavadrowning)
2955 {
2956 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2957 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2958
2959 }
2960 else if(action == sidedrowning)
2961 {
2962 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2963 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2964 }
2965 else if (action == sideswimming || action == sideswimhit)
2966 {
2967 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2968
2969 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2970 }
2971 else if(action == swimming || action==swimhit || hopclk==0xFF)
2972 {
2973 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2974 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2975
2976 if(isDiving())
2977 {
2978 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2979 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2980 }
2981 }
2982 else if(charging > 0 && attack != wHammer)
2983 {
2984 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2985 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
2986 //int32_t l=hero_count/hero_animation_speed;
2987 int32_t l=(hero_count/hero_animation_speed)&15;
2988 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
2989 l-=((l>3)?1:0)+((l>12)?1:0);
2990 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
2991 }
2992 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2993 {
2994 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2995 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2996 }
2997 else if(fallclk>0)
2998 {
2999 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
3000 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
3001 }
3002 else if(!noliftspr&&action==lifting&&isLifting())
3003 {
3004 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
3005 if(script_hero_sprite <= 0)
3006 {
3007 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
3008 auto speed = tliftclk/frames;
3009 if (speed < 1) speed = 1;
3010 auto curframe = (tliftclk-liftclk)/speed;
3011 if (!tliftclk) curframe = frames - 1;
3012 if(unsigned(curframe) < frames)
3013 tile += curframe * (extend == 2 ? 2 : 1);
3014 }
3015 }
3016 else
3017 {
3018 if(IsSideSwim())
3019 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
3020 else
3021 {
3022 if(!noliftspr&&isLifting())
3023 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
3024 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
3025 }
3026
3027 if(advancetile && (action == walking || action == climbcoverbottom || action == climbcovertop))
3028 {
3029 tile += (extend == 2 ? 2 : 1);
3030 }
3031
3032 if(dir>up)
3033 {
3034 useltm=true;
3035 shieldModify=true;
3036 }
3037
3038 if(advancetile && (action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop))
3039 {
3040 //tile+=(extend==2?2:1);
3041 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
3042 int32_t l = hero_count / hero_animation_speed;
3043 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
3044 tile += (l / 2) * (extend == 2 ? 2 : 1);
3045 }
3046 }
3047
3048 break;
3049
3050 default:
3051 break;
3052 }
3053 14929485 }
3054
3055
6/6
✓ Branch 0 taken 6682545 times.
✓ Branch 1 taken 8249787 times.
✓ Branch 2 taken 4246993 times.
✓ Branch 3 taken 2435552 times.
✓ Branch 4 taken 170841 times.
✓ Branch 5 taken 4076152 times.
14932332 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
3056
3057
2/2
✓ Branch 0 taken 14928661 times.
✓ Branch 1 taken 3671 times.
14932332 if(action==won)
3058 {
3059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3671 times.
3671 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
3060 3671 }
3061
3062
4/4
✓ Branch 0 taken 14777236 times.
✓ Branch 1 taken 155096 times.
✓ Branch 2 taken 92822 times.
✓ Branch 3 taken 14684414 times.
14932332 if(action==landhold1 || action==landhold2)
3063 {
3064 247918 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
3065
6/6
✓ Branch 0 taken 106761 times.
✓ Branch 1 taken 141157 times.
✓ Branch 2 taken 80905 times.
✓ Branch 3 taken 25856 times.
✓ Branch 4 taken 14607 times.
✓ Branch 5 taken 66298 times.
247918 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
3066 247918 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
3067 247918 }
3068
4/4
✓ Branch 0 taken 14683059 times.
✓ Branch 1 taken 1355 times.
✓ Branch 2 taken 859 times.
✓ Branch 3 taken 14682200 times.
14684414 else if(action==waterhold1 || action==waterhold2)
3069 {
3070 2214 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
3071 2214 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
3072 2214 }
3073
2/4
✓ Branch 0 taken 14682200 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14682200 times.
14682200 else if(action==sidewaterhold1 || action==sidewaterhold2)
3074 {
3075 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
3076 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
3077 }
3078
3079
3/4
✓ Branch 0 taken 14929485 times.
✓ Branch 1 taken 2847 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14929485 times.
14932332 if(action!=casting && action!=sideswimcasting)
3080 {
3081
2/2
✓ Branch 0 taken 2633329 times.
✓ Branch 1 taken 12296156 times.
14929485 if(useltm)
3082 {
3083
2/2
✓ Branch 0 taken 6558 times.
✓ Branch 1 taken 12289598 times.
12296156 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
3084 12296156 }
3085 14929485 }
3086
3087 // Stone of Agony
3088
2/2
✓ Branch 0 taken 14932300 times.
✓ Branch 1 taken 32 times.
14932332 if(agony)
3089 {
3090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
3091 32 }
3092
3093
2/2
✓ Branch 0 taken 63499 times.
✓ Branch 1 taken 14868833 times.
14932332 if(is_hitflickerframe())
3094 {
3095
4/6
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 63318 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 63318 times.
63499 int32_t temp_flicker_color = (game->get_life() > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
3096
2/4
✓ Branch 0 taken 63499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63499 times.
✗ Branch 3 not taken.
63499 if((game->get_spriteflickercolor() || temp_flicker_color) && !superman)
3097 {
3098 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
3099 sprite_flicker_color = temp_flicker_color;
3100 masked_draw(dest);
3101 }
3102 63499 }
3103 else
3104 14868833 masked_draw(dest);
3105
3106 //draw held items after Hero so they don't go behind his head
3107
4/4
✓ Branch 0 taken 14777236 times.
✓ Branch 1 taken 155096 times.
✓ Branch 2 taken 92822 times.
✓ Branch 3 taken 14684414 times.
14932332 if(action==landhold1 || action==landhold2)
3108 {
3109
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 247896 times.
247918 if(holditem > -1)
3110 {
3111
2/2
✓ Branch 0 taken 136407 times.
✓ Branch 1 taken 111489 times.
247896 if(get_qr(qr_HOLDITEMANIMATION))
3112 {
3113 136407 putitem2(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
3114 136407 }
3115 else
3116 {
3117 111489 putitem(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem);
3118 }
3119 247896 }
3120 247918 }
3121
4/4
✓ Branch 0 taken 14683059 times.
✓ Branch 1 taken 1355 times.
✓ Branch 2 taken 859 times.
✓ Branch 3 taken 14682200 times.
14684414 else if(action==waterhold1 || action==waterhold2)
3122 {
3123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2214 times.
2214 if(holditem > -1)
3124 {
3125
2/2
✓ Branch 0 taken 1562 times.
✓ Branch 1 taken 652 times.
2214 if(get_qr(qr_HOLDITEMANIMATION))
3126 {
3127 1562 putitem2(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
3128 1562 }
3129 else
3130 {
3131 652 putitem(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem);
3132 }
3133 2214 }
3134 2214 }
3135
2/4
✓ Branch 0 taken 14682200 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14682200 times.
14682200 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
3136 {
3137 if(holditem > -1)
3138 {
3139 if(get_qr(qr_HOLDITEMANIMATION))
3140 {
3141 putitem2(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
3142 }
3143 else
3144 {
3145 putitem(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem);
3146 }
3147 }
3148 }
3149
4/4
✓ Branch 0 taken 23254 times.
✓ Branch 1 taken 14909078 times.
✓ Branch 2 taken 5125 times.
✓ Branch 3 taken 18129 times.
14932332 if(fairyclk==0||(get_qr(qr_NOHEARTRING)))
3150 {
3151 14914203 goto herodraw_end;
3152 }
3153
3154 18129 double a2 = fairyclk*4.5 + 90;
3155 18129 int32_t hearts=0;
3156 18129 int32_t htile = 2;
3157
3158 18129 do
3159 {
3160 110312 int32_t nx=125;
3161
3162
2/2
✓ Branch 0 taken 64232 times.
✓ Branch 1 taken 46080 times.
110312 if(get_qr(qr_HEARTRINGFIX))
3163 {
3164 46080 nx=x;
3165 46080 }
3166
3167 110312 int32_t ny=88;
3168
3169
2/2
✓ Branch 0 taken 64232 times.
✓ Branch 1 taken 46080 times.
110312 if(get_qr(qr_HEARTRINGFIX))
3170 {
3171 46080 ny=y;
3172 46080 }
3173
3174 110312 int32_t tx = zc::math::CosD(a2)*53 +nx;
3175 110312 int32_t ty = -zc::math::SinD(a2)*53 +ny+playing_field_offset;
3176 110312 overtile8(dest,htile,tx,ty,1,0);
3177 110312 a2-=45;
3178 110312 ++hearts;
3179
2/2
✓ Branch 0 taken 92183 times.
✓ Branch 1 taken 18129 times.
220624 }
3180
2/2
✓ Branch 0 taken 9920 times.
✓ Branch 1 taken 100392 times.
110312 while(a2>90 && hearts<8);
3181 18129 }
3182 herodraw_end:
3183 16678998 xofs=oxofs;
3184 16678998 yofs=oyofs;
3185 16678998 do_primitives(dest, SPLAYER_PLAYER_DRAW, tmpscr, 0, playing_field_offset);
3186 16678998 }
3187
3188 16335025 void HeroClass::masked_draw(BITMAP* dest)
3189 {
3190 // The first sprite::draw in this function uses sprite_flicker_color
3191 // This is intended to be the player, handle this if this changes. -Moosh
3192 16335025 zfix lz, lfz;
3193
2/2
✓ Branch 0 taken 16323053 times.
✓ Branch 1 taken 11972 times.
16335025 if(lift_wpn)
3194 {
3195 11972 lz = lift_wpn->z;
3196 11972 lfz = lift_wpn->fakez;
3197 11972 }
3198
3199
12/12
✓ Branch 0 taken 6913157 times.
✓ Branch 1 taken 9421868 times.
✓ Branch 2 taken 6666939 times.
✓ Branch 3 taken 246218 times.
✓ Branch 4 taken 6573742 times.
✓ Branch 5 taken 93197 times.
✓ Branch 6 taken 6479428 times.
✓ Branch 7 taken 94314 times.
✓ Branch 8 taken 6342066 times.
✓ Branch 9 taken 137362 times.
✓ Branch 10 taken 6464957 times.
✓ Branch 11 taken 201982 times.
16335025 if(isdungeon() && currscr<128 && (x<16 || x>224 || y<18 || y>146) && !get_qr(qr_FREEFORM))
3200 {
3201 // clip under doorways
3202 201982 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
3203
3204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201982 times.
201982 if(sub!=NULL)
3205 {
3206 201982 yofs -= (playing_field_offset+16);
3207 201982 xofs -= 16;
3208 201982 sprite::draw(sub);
3209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201982 times.
201982 if(lift_wpn)
3210 {
3211 handle_lift(false);
3212 bool shad = lift_wpn->has_shadow;
3213 lift_wpn->has_shadow = false;
3214 lift_wpn->z += z;
3215 lift_wpn->fakez += fakez;
3216 lift_wpn->draw(sub);
3217 lift_wpn->has_shadow = shad;
3218 }
3219 201982 prompt_draw(sub);
3220 201982 xofs+=16;
3221 201982 yofs += (playing_field_offset+16);
3222 201982 destroy_bitmap(sub);
3223 201982 }
3224 201982 }
3225 else
3226 {
3227 16133043 sprite::draw(dest);
3228
2/2
✓ Branch 0 taken 16121071 times.
✓ Branch 1 taken 11972 times.
16133043 if(lift_wpn)
3229 {
3230 11972 handle_lift(false);
3231 11972 bool shad = lift_wpn->has_shadow;
3232 11972 lift_wpn->has_shadow = false;
3233 11972 lift_wpn->z += z;
3234 11972 lift_wpn->fakez += fakez;
3235 11972 lift_wpn->draw(dest);
3236 11972 lift_wpn->has_shadow = shad;
3237 11972 }
3238 16133043 prompt_draw(dest);
3239 }
3240
3241
2/2
✓ Branch 0 taken 16323053 times.
✓ Branch 1 taken 11972 times.
16335025 if(lift_wpn)
3242 {
3243 11972 lift_wpn->z = lz;
3244 11972 lift_wpn->fakez = lfz;
3245 11972 }
3246 16335025 return;
3247 }
3248 16335025 void HeroClass::prompt_draw(BITMAP* dest)
3249 {
3250
2/2
✓ Branch 0 taken 16325412 times.
✓ Branch 1 taken 9613 times.
16335025 if(!prompt_combo) return;
3251 9613 int32_t sx = real_x(x+xofs+prompt_x);
3252 9613 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3253 9613 sy -= fake_z(fakez);
3254 9613 overcombo(dest, sx, sy, prompt_combo, prompt_cset);
3255 9613 return;
3256 16335025 }
3257
3258 21261 void collectitem_script(int32_t id)
3259 {
3260
2/2
✓ Branch 0 taken 20964 times.
✓ Branch 1 taken 297 times.
21261 if(itemsbuf[id].collect_script)
3261 {
3262 //clear item script stack.
3263 297 FFCore.ref(ScriptType::Item, -id).Clear();
3264
3265
2/6
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 297 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
297 if ( id > 0 && !(FFCore.doscript(ScriptType::Item, -id) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3266 {
3267 297 int i = -id;
3268 297 FFCore.reset_script_engine_data(ScriptType::Item, i);
3269 297 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].collect_script, i);
3270 297 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
3271 297 }
3272 else if (id == 0 && !(FFCore.doscript(ScriptType::Item, -id) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3273 {
3274 int i = COLLECT_SCRIPT_ITEM_ZERO;
3275 FFCore.reset_script_engine_data(ScriptType::Item, i);
3276 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].collect_script, i);
3277 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
3278 }
3279 //runningItemScripts[id] = 0;
3280 297 }
3281 21261 }
3282 2000 void passiveitem_script(int32_t id, bool doRun = false)
3283 {
3284 //Passive item scripts on colelction
3285
3/6
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 1940 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2000 if(itemsbuf[id].script && ( (itemsbuf[id].flags&ITEM_PASSIVESCRIPT) && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) ))
3286 {
3287 FFCore.reset_script_engine_data(ScriptType::Item, id);
3288
3289 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3290 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3291 {
3292 FFCore.doscript(ScriptType::Item, id) = false;
3293 return;
3294 }
3295 if(doRun)
3296 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].script, id);
3297 }
3298 2000 }
3299
3300 // separate case for sword/wand/hammer/slashed weapons only
3301 // the main weapon checking is in the global function check_collisions()
3302 14162639 bool HeroClass::checkstab()
3303 {
3304
14/14
✓ Branch 0 taken 12543968 times.
✓ Branch 1 taken 1618671 times.
✓ Branch 2 taken 364376 times.
✓ Branch 3 taken 1254295 times.
✓ Branch 4 taken 338907 times.
✓ Branch 5 taken 25469 times.
✓ Branch 6 taken 274548 times.
✓ Branch 7 taken 64359 times.
✓ Branch 8 taken 274520 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 253229 times.
✓ Branch 11 taken 21291 times.
✓ Branch 12 taken 373853 times.
✓ Branch 13 taken 991589 times.
14162639 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3305 1618671 || (attackclk<=4))
3306 13171050 return false;
3307
3308 991589 weapon *w=NULL;
3309
3310 991589 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3311 991589 bool found = false;
3312 991589 int32_t melee_weapon_index = 0;
3313 991589 int32_t parentitem=-1;
3314 991589 weapon* meleeweap = nullptr;
3315
2/2
✓ Branch 0 taken 60594 times.
✓ Branch 1 taken 1101929 times.
1162523 for(int32_t i=0; i<Lwpns.Count(); i++)
3316 {
3317 1101929 w = (weapon*)Lwpns.spr(i);
3318
3319
6/6
✓ Branch 0 taken 1101891 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 18925 times.
✓ Branch 3 taken 1082966 times.
✓ Branch 4 taken 170934 times.
✓ Branch 5 taken 930995 times.
1101929 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3320 {
3321 930995 found = true;
3322 930995 melee_weapon_index = i+1;
3323 930995 meleeweap = w;
3324 // Position the sword as Hero slashes with it.
3325
4/4
✓ Branch 0 taken 875619 times.
✓ Branch 1 taken 55376 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 875505 times.
930995 if(w->id!=wHammer&&w->id!=wBugNet)
3326 875505 positionSword(w,w->parentitem);
3327
3328 930995 wx=w->x;
3329 930995 wy=w->y;
3330 930995 wz=w->z;
3331 930995 wxsz = w->hit_width;
3332 930995 wysz = w->hit_height;
3333 930995 parentitem = w->parentitem;
3334 930995 break;
3335 }
3336 170934 }
3337
3338
6/6
✓ Branch 0 taken 903295 times.
✓ Branch 1 taken 88294 times.
✓ Branch 2 taken 134807 times.
✓ Branch 3 taken 768488 times.
✓ Branch 4 taken 39264 times.
✓ Branch 5 taken 95543 times.
991589 if(attack==wSword && attackclk>=14 && charging==0)
3339 95543 return false;
3340
3341
2/2
✓ Branch 0 taken 835452 times.
✓ Branch 1 taken 60594 times.
896046 if(!found)
3342 60594 return false;
3343
3344
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 835029 times.
835452 if(attack == wFire)
3345 423 return false;
3346
3347
2/2
✓ Branch 0 taken 779653 times.
✓ Branch 1 taken 55376 times.
835029 if(attack==wHammer)
3348 {
3349
2/2
✓ Branch 0 taken 21946 times.
✓ Branch 1 taken 33430 times.
55376 if(attackclk<15)
3350 {
3351
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3427 times.
✓ Branch 2 taken 5263 times.
✓ Branch 3 taken 7197 times.
✓ Branch 4 taken 6059 times.
21946 switch(w->dir)
3352 {
3353 case up:
3354 3427 wx=x-1;
3355 3427 wy=y-4;
3356 3427 break;
3357
3358 case down:
3359 5263 wx=x+8;
3360 5263 wy=y+28;
3361 5263 break; // This is consistent with 2.10
3362
3363 case left:
3364 7197 wx=x-13;
3365 7197 wy=y+14;
3366 7197 break;
3367
3368 case right:
3369 6059 wx=x+21;
3370 6059 wy=y+14;
3371 6059 break;
3372 }
3373
3374
6/8
✓ Branch 0 taken 2170 times.
✓ Branch 1 taken 19776 times.
✓ Branch 2 taken 2170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 2165 times.
21946 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3375 {
3376 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3377 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3378 switch(dir)
3379 {
3380 case up:
3381 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3382 break;
3383
3384 case down:
3385 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3386 break;
3387
3388 case left:
3389 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3390 break;
3391
3392 case right:
3393 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3394 break;
3395 }
3396 */
3397 2165 }
3398
3399 21946 return false;
3400 }
3401
2/2
✓ Branch 0 taken 31300 times.
✓ Branch 1 taken 2130 times.
33430 else if(attackclk==15)
3402 {
3403 // Hammer's reach needs adjusted slightly for backward compatibility
3404
2/2
✓ Branch 0 taken 1793 times.
✓ Branch 1 taken 337 times.
2130 if(w->dir==up)
3405 337 w->hyofs-=1;
3406
2/2
✓ Branch 0 taken 1097 times.
✓ Branch 1 taken 696 times.
1793 else if(w->dir==left)
3407 696 w->hxofs-=2;
3408 2130 }
3409 33430 }
3410
3411 // The return of Spaghetti Code Constants!
3412
6/6
✓ Branch 0 taken 16297 times.
✓ Branch 1 taken 796786 times.
✓ Branch 2 taken 763224 times.
✓ Branch 3 taken 33562 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 33544 times.
813083 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3413
4/4
✓ Branch 0 taken 80798 times.
✓ Branch 1 taken 732285 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 80770 times.
813083 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3414 813083 itemid = vbound(itemid, 0, MAXITEMS-1);
3415
3416 // The sword offsets aren't based on anything other than what felt about right
3417 // compared to the NES game and what mostly kept it from hitting things that
3418 // should clearly be out of range. They could probably still use more tweaking.
3419 // Don't use 2.10 for reference; it's pretty far off.
3420 // - Saf
3421
3422
6/6
✓ Branch 0 taken 430702 times.
✓ Branch 1 taken 382381 times.
✓ Branch 2 taken 24750 times.
✓ Branch 3 taken 405952 times.
✓ Branch 4 taken 25521 times.
✓ Branch 5 taken 405181 times.
813083 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & ITEM_FLAG4)
3423 {
3424
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 70471 times.
✓ Branch 2 taken 88995 times.
✓ Branch 3 taken 124747 times.
✓ Branch 4 taken 120968 times.
405181 switch(w->dir)
3425 {
3426 case up:
3427
2/2
✓ Branch 0 taken 48158 times.
✓ Branch 1 taken 22313 times.
70471 if(attackclk<8)
3428 {
3429 22313 wy-=4;
3430 22313 }
3431
3432 70471 break;
3433
3434 case down:
3435 //if(attackclk<8)
3436 {
3437 88995 wy-=2;
3438 }
3439 88995 break;
3440
3441 case left:
3442
3443 //if(attackclk<8)
3444 {
3445 124747 wx+=2;
3446 }
3447
3448 124747 break;
3449
3450 case right:
3451
3452 //if(attackclk<8)
3453 {
3454 120968 wx-=3;
3455 //wy+=((spins>0 || get_qr(qr_SLASHFLIPFIX)) ? -4 : 4);
3456 }
3457
3458 120968 break;
3459 }
3460 405181 }
3461
3462
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 164927 times.
✓ Branch 2 taken 175844 times.
✓ Branch 3 taken 236275 times.
✓ Branch 4 taken 236037 times.
813083 switch(w->dir)
3463 {
3464 case up:
3465 164927 wx+=2;
3466 164927 break;
3467
3468 case down:
3469 175844 break;
3470
3471 case left:
3472 236275 wy-=3;
3473 236275 break;
3474
3475 case right:
3476 236037 wy-=3;
3477 236037 break;
3478 }
3479
3480 813083 wx+=w->hxofs;
3481 813083 wy+=w->hyofs;
3482 813083 wy-=(w->fakez).getInt();
3483
3484
2/2
✓ Branch 0 taken 806654 times.
✓ Branch 1 taken 3490170 times.
4296824 for(int32_t i=0; i<guys.Count(); i++)
3485 {
3486
2/2
✓ Branch 0 taken 3490075 times.
✓ Branch 1 taken 95 times.
3490170 if(attack==wBugNet) break;
3487 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3488
6/6
✓ Branch 0 taken 74046 times.
✓ Branch 1 taken 3416029 times.
✓ Branch 2 taken 73451 times.
✓ Branch 3 taken 595 times.
✓ Branch 4 taken 71774 times.
✓ Branch 5 taken 1677 times.
3490631 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3489
5/6
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2506 times.
✓ Branch 2 taken 3312889 times.
✓ Branch 3 taken 103848 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3416737 times.
3418301 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & ITEM_FLAG3))
3490
4/4
✓ Branch 0 taken 120214 times.
✓ Branch 1 taken 3296523 times.
✓ Branch 2 taken 556 times.
✓ Branch 3 taken 119658 times.
3416737 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3491 {
3492 // Checking the whimsical ring for every collision check causes
3493 // an odd bug. It's much more likely to activate on a 0-damage
3494 // weapon, since a 0-damage hit won't make the enemy invulnerable
3495 // to damaging hits in the following frames.
3496
3497 74280 int32_t whimsyid = current_item_id(itype_whimsicalring);
3498
3499 74280 int32_t dmg = weaponattackpower(itemid);
3500
2/2
✓ Branch 0 taken 72371 times.
✓ Branch 1 taken 1909 times.
74280 if(whimsyid>-1)
3501 {
3502
3/4
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1793 times.
✓ Branch 3 taken 116 times.
1909 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3503 116 dmg += current_item_power(itype_whimsicalring);
3504 1793 else whimsyid = -1;
3505 1909 }
3506 74280 int32_t atkringid = current_item_id(itype_atkring);
3507
2/2
✓ Branch 0 taken 74272 times.
✓ Branch 1 taken 8 times.
74280 if(atkringid>-1)
3508 {
3509 8 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3510 8 dmg += itemsbuf[atkringid].misc1; //Additive
3511 8 }
3512
3513 74280 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn,w);
3514 74280 enemy *e = (enemy*)guys.spr(i);
3515
2/2
✓ Branch 0 taken 25166 times.
✓ Branch 1 taken 49114 times.
74280 if (h == -1)
3516 {
3517 49114 e->hitby[HIT_BY_LWEAPON] = melee_weapon_index;
3518 49114 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
3519 49114 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
3520
1/2
✓ Branch 0 taken 49114 times.
✗ Branch 1 not taken.
49114 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
3521 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
3522 49114 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
3523 49114 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
3524 49114 } //temp_hit = true; }
3525 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3526
3527
4/4
✓ Branch 0 taken 49114 times.
✓ Branch 1 taken 25166 times.
✓ Branch 2 taken 49069 times.
✓ Branch 3 taken 45 times.
74280 if(h<0 && whimsyid>-1)
3528 {
3529 45 sfx(itemsbuf[whimsyid].usesound);
3530 45 }
3531
3532
4/4
✓ Branch 0 taken 63036 times.
✓ Branch 1 taken 11244 times.
✓ Branch 2 taken 62556 times.
✓ Branch 3 taken 480 times.
74280 if(h && charging>0)
3533 {
3534 480 attackclk = SWORDTAPFRAME;
3535 480 spins=0;
3536 480 }
3537
3538
8/8
✓ Branch 0 taken 63036 times.
✓ Branch 1 taken 11244 times.
✓ Branch 2 taken 53406 times.
✓ Branch 3 taken 9630 times.
✓ Branch 4 taken 53372 times.
✓ Branch 5 taken 34 times.
✓ Branch 6 taken 1216 times.
✓ Branch 7 taken 52156 times.
74280 if(h && hclk==0 && inlikelike != 1 && !get_qr(qr_DYING_ENEMIES_IGNORE_STUN))
3539 {
3540
2/2
✓ Branch 0 taken 51999 times.
✓ Branch 1 taken 157 times.
52156 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3541 {
3542 157 hithero(i);
3543 157 }
3544 52156 }
3545
3546
2/2
✓ Branch 0 taken 67004 times.
✓ Branch 1 taken 7276 times.
74280 if(h==2)
3547 7276 break;
3548 67004 }
3549 3483741 }
3550
3551
2/2
✓ Branch 0 taken 18938 times.
✓ Branch 1 taken 794031 times.
1626994 if(attack == wBugNet
3552
3/4
✓ Branch 0 taken 812969 times.
✓ Branch 1 taken 1056 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 812969 times.
814025 || (parentitem==-1&&!get_qr(qr_NOITEMMELEE))
3553
1/2
✓ Branch 0 taken 812969 times.
✗ Branch 1 not taken.
812969 || (parentitem>-1&&!(itemsbuf[parentitem].flags & ITEM_FLAG7)))
3554 {
3555
3/4
✓ Branch 0 taken 794973 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
795087 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3556
2/2
✓ Branch 0 taken 795087 times.
✓ Branch 1 taken 254215 times.
1049302 for(int32_t j=0; j<items.Count(); j++)
3557 {
3558 254215 item* ptr = (item*)items.spr(j);
3559
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 254195 times.
254216 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3560
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
20 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & ITEM_FLAG1));
3561
3562
2/4
✓ Branch 0 taken 254215 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 254215 times.
✗ Branch 3 not taken.
254215 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3563 continue; //No picking these up unless you have a bottle to fill!
3564
5/6
✓ Branch 0 taken 254188 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 46889 times.
✓ Branch 3 taken 207299 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 46889 times.
254215 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3565 {
3566
7/8
✓ Branch 0 taken 207299 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 96779 times.
✓ Branch 3 taken 110520 times.
✓ Branch 4 taken 110547 times.
✓ Branch 5 taken 96779 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 110547 times.
207326 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3567 {
3568
6/6
✓ Branch 0 taken 103623 times.
✓ Branch 1 taken 6924 times.
✓ Branch 2 taken 981 times.
✓ Branch 3 taken 102642 times.
✓ Branch 4 taken 103608 times.
✓ Branch 5 taken 6939 times.
214167 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3569
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 978 times.
✓ Branch 2 taken 100869 times.
✓ Branch 3 taken 2751 times.
103623 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3570 {
3571 6939 int32_t pickup = ptr->pickup;
3572 6939 int32_t id2 = ptr->id;
3573 6939 int32_t pstr = ptr->pstring;
3574 6939 int32_t pstr_flags = ptr->pickup_string_flags;
3575
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6938 times.
6939 if(!dofairy)
3576 {
3577 6938 std::vector<int32_t> &ev = FFCore.eventData;
3578 6938 ev.clear();
3579 6938 ev.push_back(id2*10000);
3580 6938 ev.push_back(pickup*10000);
3581 6938 ev.push_back(pstr*10000);
3582 6938 ev.push_back(pstr_flags*10000);
3583 6938 ev.push_back(0);
3584 6938 ev.push_back(ptr->getUID());
3585 6938 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3586 6938 ev.push_back(w->getUID());
3587
3588 6938 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3589 6938 bool nullify = ev[4] != 0;
3590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6938 times.
6938 if(nullify) continue;
3591 6938 id2 = ev[0]/10000;
3592 6938 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3593 6938 pstr = ev[2] / 10000;
3594 6938 pstr_flags = ev[3] / 10000;
3595 6938 }
3596
3597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6939 times.
6939 if(pickup&ipONETIME) // set mITEM for one-time-only items
3598 setmapflag(mITEM);
3599
1/2
✓ Branch 0 taken 6939 times.
✗ Branch 1 not taken.
6939 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3600 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3601
3602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6939 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6939 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3603 setxmapflag(1<<ptr->pickupexstate);
3604
1/2
✓ Branch 0 taken 6939 times.
✗ Branch 1 not taken.
6939 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3605 {
3606 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
3607 hidden_entrance(0, true, false, -5);
3608 }
3609 //!DIMI
3610
3611
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6938 times.
6939 if(dofairy)
3612 {
3613 1 game->fillBottle(itemsbuf[ptr->id].misc4);
3614 1 }
3615 else
3616 {
3617 6938 collectitem_script(id2);
3618
3619 6938 getitem(id2, ptr->noSound, true);
3620 }
3621 6939 items.del(j);
3622
3623
2/2
✓ Branch 0 taken 7995 times.
✓ Branch 1 taken 6939 times.
14934 for(int32_t i=0; i<Lwpns.Count(); i++)
3624 {
3625 7995 weapon *w2 = (weapon*)Lwpns.spr(i);
3626
3627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7995 times.
7995 if(w2->dragging==j)
3628 {
3629 w2->dragging=-1;
3630 }
3631
1/2
✓ Branch 0 taken 7995 times.
✗ Branch 1 not taken.
7995 else if(w2->dragging>j)
3632 {
3633 w2->dragging-=1;
3634 }
3635 7995 }
3636
3637
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6939 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6939 if ( (pstr > 0 && pstr < msg_count) )
3638 {
3639 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3640 {
3641 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3642 FFCore.SetItemMessagePlayed(id2);
3643 donewmsg(pstr);
3644 break;
3645 }
3646 }
3647
3648 6939 --j;
3649 6939 }
3650 110547 }
3651 207326 }
3652 254215 }
3653 795087 }
3654
3655
4/4
✓ Branch 0 taken 813065 times.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 812951 times.
814025 if(attack==wCByrna || attack==wBugNet)
3656 1074 return false;
3657
3658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 812951 times.
812951 if(meleeweap->no_triggers())
3659 return false;
3660
3661
2/2
✓ Branch 0 taken 763224 times.
✓ Branch 1 taken 49727 times.
812951 if(attack==wSword)
3662 {
3663
2/2
✓ Branch 0 taken 677167 times.
✓ Branch 1 taken 86057 times.
763224 if(attackclk == 6)
3664 {
3665
2/2
✓ Branch 0 taken 15146032 times.
✓ Branch 1 taken 86057 times.
15232089 for(int32_t q=0; q<176; q++)
3666 {
3667 15146032 set_bit(screengrid,q,0);
3668 15146032 set_bit(screengrid_layer[0],q,0);
3669 15146032 set_bit(screengrid_layer[1],q,0);
3670 15146032 }
3671
3672
2/2
✓ Branch 0 taken 1376912 times.
✓ Branch 1 taken 86057 times.
1462969 for(dword q = MAXFFCS/8; q > 0; --q)
3673 1376912 ffcgrid[q-1] = 0;
3674 86057 }
3675
3676
4/4
✓ Branch 0 taken 156552 times.
✓ Branch 1 taken 606672 times.
✓ Branch 2 taken 72482 times.
✓ Branch 3 taken 84070 times.
763224 if(dir==up && ((x.getInt()&15)==0))
3677 {
3678 72482 check_slash_block(wx,wy);
3679 72482 check_slash_block(wx,wy+8);
3680
3681 //layers
3682 72482 check_slash_block_layer(wx,wy,1);
3683 72482 check_slash_block_layer(wx,wy+8,1);
3684 72482 check_slash_block_layer(wx,wy,1);
3685 72482 check_slash_block_layer(wx,wy+8,1);
3686 //2
3687 72482 check_slash_block_layer(wx,wy,2);
3688 72482 check_slash_block_layer(wx,wy+8,2);
3689 72482 check_slash_block_layer(wx,wy,2);
3690 72482 check_slash_block_layer(wx,wy+8,2);
3691 72482 }
3692
8/10
✓ Branch 0 taken 84070 times.
✓ Branch 1 taken 606672 times.
✓ Branch 2 taken 25919 times.
✓ Branch 3 taken 58151 times.
✓ Branch 4 taken 240 times.
✓ Branch 5 taken 25679 times.
✓ Branch 6 taken 240 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 240 times.
690742 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3693 {
3694 83830 check_slash_block(wx,wy);
3695 83830 check_slash_block(wx,wy+8);
3696 83830 check_slash_block(wx+8,wy);
3697 83830 check_slash_block(wx+8,wy+8);
3698 ///layer 1
3699 83830 check_slash_block_layer(wx,wy,1);
3700 83830 check_slash_block_layer(wx,wy+8,1);
3701 83830 check_slash_block_layer(wx+8,wy,1);
3702 83830 check_slash_block_layer(wx+8,wy+8,1);
3703 ///layer 2
3704 83830 check_slash_block_layer(wx,wy,2);
3705 83830 check_slash_block_layer(wx,wy+8,2);
3706 83830 check_slash_block_layer(wx+8,wy,2);
3707 83830 check_slash_block_layer(wx+8,wy+8,2);
3708 83830 }
3709
4/4
✓ Branch 0 taken 165394 times.
✓ Branch 1 taken 597830 times.
✓ Branch 2 taken 86354 times.
✓ Branch 3 taken 79040 times.
763224 if(dir==down && ((x.getInt()&15)==0))
3710 {
3711 79040 check_slash_block(wx,wy+wysz-8);
3712 79040 check_slash_block(wx,wy+wysz);
3713
3714 //layer 1
3715 79040 check_slash_block_layer(wx,wy+wysz-8,1);
3716 79040 check_slash_block_layer(wx,wy+wysz,1);
3717 //layer 2
3718 79040 check_slash_block_layer(wx,wy+wysz-8,2);
3719 79040 check_slash_block_layer(wx,wy+wysz,2);
3720 79040 }
3721
8/10
✓ Branch 0 taken 86354 times.
✓ Branch 1 taken 597830 times.
✓ Branch 2 taken 34826 times.
✓ Branch 3 taken 51528 times.
✓ Branch 4 taken 333 times.
✓ Branch 5 taken 34493 times.
✓ Branch 6 taken 333 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 333 times.
684184 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3722 {
3723 86021 check_slash_block(wx,wy+wysz-8);
3724 86021 check_slash_block(wx,wy+wysz);
3725 86021 check_slash_block(wx+8,wy+wysz-8);
3726 86021 check_slash_block(wx+8,wy+wysz);
3727 //layer 1
3728 86021 check_slash_block_layer(wx,wy+wysz-8,1);
3729 86021 check_slash_block_layer(wx,wy+wysz,1);
3730 86021 check_slash_block_layer(wx+8,wy+wysz-8,1);
3731 86021 check_slash_block_layer(wx+8,wy+wysz,1);
3732 //layer 2
3733 86021 check_slash_block_layer(wx,wy+wysz-8,2);
3734 86021 check_slash_block_layer(wx,wy+wysz,2);
3735 86021 check_slash_block_layer(wx+8,wy+wysz-8,2);
3736 86021 check_slash_block_layer(wx+8,wy+wysz,2);
3737 86021 }
3738
3739
2/2
✓ Branch 0 taken 544005 times.
✓ Branch 1 taken 219219 times.
763224 if(dir==left)
3740 {
3741 219219 check_slash_block(wx,wy+8);
3742 219219 check_slash_block(wx+8,wy+8);
3743 //layer 1
3744 219219 check_slash_block_layer(wx,wy+8,1);
3745 219219 check_slash_block_layer(wx+8,wy+8,1);
3746 //layer 2
3747 219219 check_slash_block_layer(wx,wy+8,2);
3748 219219 check_slash_block_layer(wx+8,wy+8,2);
3749 219219 }
3750
3751
2/2
✓ Branch 0 taken 541165 times.
✓ Branch 1 taken 222059 times.
763224 if(dir==right)
3752 {
3753 222059 check_slash_block(wx+wxsz,wy+8);
3754 222059 check_slash_block(wx+wxsz-8,wy+8);
3755 //layer 1
3756 222059 check_slash_block_layer(wx+wxsz,wy+8,1);
3757 222059 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3758 //layer 2
3759 222059 check_slash_block_layer(wx+wxsz,wy+8,2);
3760 222059 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3761 222059 }
3762 763224 }
3763
2/2
✓ Branch 0 taken 16297 times.
✓ Branch 1 taken 33430 times.
49727 else if(attack==wWand)
3764 {
3765
1/2
✓ Branch 0 taken 16297 times.
✗ Branch 1 not taken.
16297 if(attackclk == 5)
3766 {
3767 for(int32_t q=0; q<176; q++)
3768 {
3769 set_bit(screengrid,q,0);
3770 set_bit(screengrid_layer[0],q,0);
3771 set_bit(screengrid_layer[1],q,0);
3772 }
3773
3774 for(dword q = MAXFFCS/8; q > 0; --q)
3775 ffcgrid[q-1] = 0;
3776 }
3777
3778 // cutable blocks
3779
4/4
✓ Branch 0 taken 3074 times.
✓ Branch 1 taken 13223 times.
✓ Branch 2 taken 1386 times.
✓ Branch 3 taken 1688 times.
16297 if(dir==up && (x.getInt()&15)==0)
3780 {
3781 1386 check_wand_block(wx,wy);
3782 1386 check_wand_block(wx,wy+8);
3783 1386 }
3784
5/10
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 13223 times.
✓ Branch 2 taken 813 times.
✓ Branch 3 taken 875 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 813 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
14911 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3785 {
3786 1688 check_wand_block(wx,wy);
3787 1688 check_wand_block(wx,wy+8);
3788 1688 check_wand_block(wx+8,wy);
3789 1688 check_wand_block(wx+8,wy+8);
3790 1688 }
3791
3792
4/4
✓ Branch 0 taken 2366 times.
✓ Branch 1 taken 13931 times.
✓ Branch 2 taken 1135 times.
✓ Branch 3 taken 1231 times.
16297 if(dir==down && (x.getInt()&15)==0)
3793 {
3794 1231 check_wand_block(wx,wy+wysz-8);
3795 1231 check_wand_block(wx,wy+wysz);
3796 1231 }
3797
5/10
✓ Branch 0 taken 1135 times.
✓ Branch 1 taken 13931 times.
✓ Branch 2 taken 307 times.
✓ Branch 3 taken 828 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 307 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
15066 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3798 {
3799 1135 check_wand_block(wx,wy+wysz-8);
3800 1135 check_wand_block(wx,wy+wysz);
3801 1135 check_wand_block(wx+8,wy+wysz-8);
3802 1135 check_wand_block(wx+8,wy+wysz);
3803 1135 }
3804
3805
2/2
✓ Branch 0 taken 10184 times.
✓ Branch 1 taken 6113 times.
16297 if(dir==left)
3806 {
3807 6113 check_wand_block(wx,y+8);
3808 6113 check_wand_block(wx+8,y+8);
3809 6113 }
3810
3811
2/2
✓ Branch 0 taken 11553 times.
✓ Branch 1 taken 4744 times.
16297 if(dir==right)
3812 {
3813 4744 check_wand_block(wx+wxsz,y+8);
3814 4744 check_wand_block(wx+wxsz-8,y+8);
3815 4744 }
3816 16297 }
3817
4/8
✓ Branch 0 taken 33430 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31300 times.
✓ Branch 3 taken 2130 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31300 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
33430 else if((attack==wHammer) && ((attackclk==15) || ( spins>0 && attackclk >=15 )))
3818 {
3819 // poundable blocks
3820
2/2
✓ Branch 0 taken 374880 times.
✓ Branch 1 taken 2130 times.
377010 for(int32_t q=0; q<176; q++)
3821 {
3822 374880 set_bit(screengrid,q,0);
3823 374880 set_bit(screengrid_layer[0],q,0);
3824 374880 set_bit(screengrid_layer[1],q,0);
3825 374880 }
3826
3827
2/2
✓ Branch 0 taken 34080 times.
✓ Branch 1 taken 2130 times.
36210 for(dword q = MAXFFCS/8; q > 0; --q)
3828 34080 ffcgrid[q-1] = 0;
3829
3830
4/4
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 1792 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 164 times.
2130 if(dir==up && (x.getInt()&15)==0)
3831 {
3832 164 check_pound_block(wx,wy);
3833 164 check_pound_block(wx,wy+8);
3834 164 }
3835
5/10
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 1792 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 127 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1966 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3836 {
3837 174 check_pound_block(wx,wy);
3838 174 check_pound_block(wx,wy+8);
3839 174 check_pound_block(wx+8,wy);
3840 174 check_pound_block(wx+8,wy+8);
3841 174 }
3842
3843
4/4
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 1632 times.
✓ Branch 2 taken 258 times.
✓ Branch 3 taken 240 times.
2130 if(dir==down && (x.getInt()&15)==0)
3844 {
3845 240 check_pound_block(wx,wy+wysz-8);
3846 240 check_pound_block(wx,wy+wysz);
3847 240 }
3848
8/10
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 1632 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 152 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
1890 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3849 {
3850 257 check_pound_block(wx,wy+wysz-8);
3851 257 check_pound_block(wx,wy+wysz);
3852 257 check_pound_block(wx+8,wy+wysz-8);
3853 257 check_pound_block(wx+8,wy+wysz);
3854 257 }
3855
3856
2/2
✓ Branch 0 taken 1429 times.
✓ Branch 1 taken 701 times.
2130 if(dir==left)
3857 {
3858 701 check_pound_block(wx,y+8);
3859 701 check_pound_block(wx+8,y+8);
3860 701 }
3861
3862
2/2
✓ Branch 0 taken 1537 times.
✓ Branch 1 taken 593 times.
2130 if(dir==right)
3863 {
3864 593 check_pound_block(wx+wxsz,y+8);
3865 593 check_pound_block(wx+wxsz-8,y+8);
3866 593 }
3867 2130 }
3868 31300 else return false;
3869
3870 781651 return true;
3871 14163581 }
3872
3873 4019936 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3874 {
3875
2/2
✓ Branch 0 taken 3824612 times.
✓ Branch 1 taken 195324 times.
4019936 if(!(get_qr(qr_BUSHESONLAYERS1AND2)))
3876 {
3877 //zprint("bit off\n");
3878 3824612 return;
3879 }
3880 //keep things inside the screen boundaries
3881 195324 bx=vbound(bx, 0, 255);
3882 195324 by=vbound(by, 0, 176);
3883 195324 int32_t fx=vbound(bx, 0, 255);
3884 195324 int32_t fy=vbound(by, 0, 176);
3885 //first things first
3886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 195324 times.
195324 if(attack!=wSword)
3887 return;
3888
3889
4/6
✓ Branch 0 taken 195324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195324 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1984 times.
✓ Branch 5 taken 20224 times.
217532 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3890
4/4
✓ Branch 0 taken 179972 times.
✓ Branch 1 taken 15352 times.
✓ Branch 2 taken 22208 times.
✓ Branch 3 taken 157764 times.
195324 || (attackclk>SWORDTAPFRAME && tapping))
3891 17336 return;
3892
3893 //find out which combo row/column the coordinates are in
3894 177988 bx &= 0xF0;
3895 177988 by &= 0xF0;
3896
3897
3898 177988 int32_t flag = MAPFLAGL(layer,bx,by);
3899 177988 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3900 177988 int32_t cid = MAPCOMBOL(layer,bx,by);
3901 177988 int32_t type = combobuf[cid].type;
3902
1/2
✓ Branch 0 taken 177988 times.
✗ Branch 1 not taken.
177988 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3903 type = cNONE;
3904 //zprint("cid is: %d\n", cid);
3905 //zprint("type is: %d\n", type);
3906 177988 int32_t i = (bx>>4) + by;
3907
3908
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 177958 times.
177988 if(i > 175)
3909 30 return;
3910
3911 177958 bool ignorescreen=false;
3912
3913
4/4
✓ Branch 0 taken 177256 times.
✓ Branch 1 taken 702 times.
✓ Branch 2 taken 176971 times.
✓ Branch 3 taken 285 times.
177958 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3914 177673 return;
3915
3916
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 187 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
285 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3917
3918
3/4
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 188 times.
285 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3919
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(isCuttableNextType(type))
3920 {
3921 285 FFCore.tempScreens[layer]->data[i]++;
3922 285 }
3923 else
3924 {
3925 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
3926 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
3927 FFCore.tempScreens[layer]->sflag[i] = 0;
3928 }
3929
2/8
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 285 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
285 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3930 {
3931 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3932 sfx(tmpscr->secretsfx);
3933 }
3934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
285 else if(isCuttableItemType(type))
3935 {
3936 285 int32_t it = -1;
3937 285 int32_t thedropset = -1;
3938
3939 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
3940
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 254 times.
285 if ( (combobuf[cid].usrflags&cflag2) )
3941 {
3942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(combobuf[cid].usrflags&cflag11)
3943 it = combobuf[cid].attribytes[1];
3944 else
3945 {
3946 31 it = select_dropitem(combobuf[cid].attribytes[1]);
3947 31 thedropset = combobuf[cid].attribytes[1];
3948 }
3949 31 }
3950 else
3951 {
3952 254 it = select_dropitem(12);
3953 254 thedropset = 12;
3954 }
3955
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 96 times.
285 if(it!=-1)
3956 {
3957
4/8
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
96 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3958 96 itm->from_dropset = thedropset;
3959 96 items.add(itm);
3960 96 }
3961 285 }
3962
3963 285 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
3964
3965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
285 if(get_qr(qr_MORESOUNDS))
3966 {
3967
5/6
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 153 times.
✓ Branch 5 taken 34 times.
285 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3968 {
3969
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if (combobuf[cid].usrflags&cflag3)
3970 {
3971 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3972 }
3973 34 }
3974 else
3975 {
3976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 251 times.
251 if (combobuf[cid].usrflags&cflag3)
3977 {
3978 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3979 }
3980 251 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
3981 }
3982 285 }
3983
3984 285 spawn_decoration_xy(combobuf[cid], fx, fy);
3985 4019936 }
3986
3987 1865004 void HeroClass::check_slash_block(int32_t bx, int32_t by)
3988 {
3989 //keep things inside the screen boundaries
3990 1865004 bx=vbound(bx, 0, 255);
3991 1865004 by=vbound(by, 0, 176);
3992 1865004 int32_t fx=vbound(bx, 0, 255);
3993 1865004 int32_t fy=vbound(by, 0, 176);
3994 //first things first
3995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1865004 times.
1865004 if(attack!=wSword)
3996 return;
3997
3998
5/6
✓ Branch 0 taken 1864860 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 1864860 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9720 times.
✓ Branch 5 taken 208714 times.
2083438 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3999
4/4
✓ Branch 0 taken 1779568 times.
✓ Branch 1 taken 85292 times.
✓ Branch 2 taken 218434 times.
✓ Branch 3 taken 1561134 times.
1864860 || (attackclk>SWORDTAPFRAME && tapping))
4000 95156 return;
4001
4002 //find out which combo row/column the coordinates are in
4003 1769848 bx &= 0xF0;
4004 1769848 by &= 0xF0;
4005
4006 1769848 int cid = MAPCOMBO(bx,by);
4007 1769848 int cid_ff = MAPFFCOMBO(fx,fy);
4008 1769848 int current_ffcombo = getFFCAt(fx,fy);
4009 1769848 newcombo const& cmb = combobuf[cid];
4010 1769848 newcombo const& cmb_ff = combobuf[cid_ff];
4011 1769848 int type = cmb.type;
4012 1769848 int type2 = cmb_ff.type;
4013 1769848 int flag = MAPFLAG(bx,by);
4014 1769848 int flag2 = cmb.flag;
4015 1769848 int flag3 = cmb_ff.flag;
4016 1769848 int i = (bx>>4) + by;
4017
4018
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 1769655 times.
1769848 if(i > 175)
4019 193 return;
4020
4021 1769655 bool ignorescreen=false;
4022 1769655 bool ignoreffc=false;
4023
4024
2/2
✓ Branch 0 taken 1744061 times.
✓ Branch 1 taken 25594 times.
1769655 if(get_bit(screengrid, i) != 0)
4025 {
4026 25594 ignorescreen = true;
4027 25594 }
4028
2/2
✓ Branch 0 taken 1744056 times.
✓ Branch 1 taken 5 times.
1744061 else if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
4029 5 ignorescreen = true;
4030
4031
4032
4033
3/4
✓ Branch 0 taken 11996 times.
✓ Branch 1 taken 1757659 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11996 times.
1769655 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4034 {
4035 1757659 ignoreffc = true;
4036 1757659 }
4037
2/2
✓ Branch 0 taken 11977 times.
✓ Branch 1 taken 19 times.
11996 else if(cmb_ff.triggerflags[0] & combotriggerONLYGENTRIG)
4038 19 ignoreffc = true;
4039
4040
4/4
✓ Branch 0 taken 1751917 times.
✓ Branch 1 taken 17738 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 1751503 times.
3521204 if(!isCuttableType(type) &&
4041
6/6
✓ Branch 0 taken 3935 times.
✓ Branch 1 taken 1747982 times.
✓ Branch 2 taken 1751549 times.
✓ Branch 3 taken 368 times.
✓ Branch 4 taken 4688 times.
✓ Branch 5 taken 1746861 times.
1751917 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4042 {
4043 1751503 ignorescreen = true;
4044 1751503 }
4045
4046
4/4
✓ Branch 0 taken 1769636 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1769635 times.
3539291 if(!isCuttableType(type2) &&
4047
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1769635 times.
1769636 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4048 {
4049 1769635 ignoreffc = true;
4050 1769635 }
4051
4052 1769655 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4053
4054
4/4
✓ Branch 0 taken 71758 times.
✓ Branch 1 taken 1697897 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 71702 times.
1769655 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4055 1769655 byte skipsecrets = 0;
4056
4057
2/2
✓ Branch 0 taken 1763018 times.
✓ Branch 1 taken 6637 times.
1769655 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4058 {
4059
2/2
✓ Branch 0 taken 5639 times.
✓ Branch 1 taken 998 times.
6637 if (get_qr(qr_OLD_SLASHNEXT_SECRETS))
4060 {
4061 5639 skipsecrets = 0;
4062 5639 }
4063 998 else skipsecrets = 1; ;
4064 6637 }
4065
4066
6/6
✓ Branch 0 taken 16569 times.
✓ Branch 1 taken 1753086 times.
✓ Branch 2 taken 993 times.
✓ Branch 3 taken 15576 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 1037 times.
1769655 if(!ignorescreen && (!skipsecrets || !get_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
4067 {
4068
6/6
✓ Branch 0 taken 1955 times.
✓ Branch 1 taken 14658 times.
✓ Branch 2 taken 1526 times.
✓ Branch 3 taken 429 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 1496 times.
16613 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
4069 {
4070 1496 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4071 1496 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4072 1496 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4073 1496 }
4074
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15113 times.
15117 else if(flag == mfARMOS_SECRET)
4075 {
4076 4 s->data[i] = s->secretcombo[sSTAIRS];
4077 4 s->cset[i] = s->secretcset[sSTAIRS];
4078 4 s->sflag[i] = s->secretflag[sSTAIRS];
4079 4 sfx(tmpscr->secretsfx);
4080 4 }
4081
4/4
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 14720 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 14698 times.
15113 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4082 {
4083
4/4
✓ Branch 0 taken 1074 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 858 times.
✓ Branch 3 taken 371 times.
1273 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4084 {
4085 858 findentrance(bx,by,mfSWORD+i2,true);
4086 858 }
4087
4088 371 findentrance(bx,by,mfSTRIKE,true);
4089 371 }
4090
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 14686 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
14698 else if(((flag2 >= 16)&&(flag2 <= 31)))
4091 {
4092 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4093 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4094 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4095 }
4096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14698 times.
14698 else if(flag2 == mfARMOS_SECRET)
4097 {
4098 s->data[i] = s->secretcombo[sSTAIRS];
4099 s->cset[i] = s->secretcset[sSTAIRS];
4100 s->sflag[i] = s->secretflag[sSTAIRS];
4101 sfx(tmpscr->secretsfx);
4102 }
4103
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 14686 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14686 times.
14698 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4104 {
4105
3/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 12 times.
32 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4106 {
4107 20 findentrance(bx,by,mfSWORD+i2,true);
4108 20 }
4109
4110 12 findentrance(bx,by,mfSTRIKE,true);
4111 12 }
4112 else
4113 {
4114
2/2
✓ Branch 0 taken 5079 times.
✓ Branch 1 taken 9607 times.
14686 if(isCuttableNextType(type))
4115 {
4116 5079 s->data[i]++;
4117 5079 }
4118 else
4119 {
4120 9607 s->data[i] = s->undercombo;
4121 9607 s->cset[i] = s->undercset;
4122 9607 s->sflag[i] = 0;
4123 }
4124
4125 //pausenow=true;
4126 }
4127 16569 }
4128
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1753130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1753130 else if(!ignorescreen && skipsecrets)
4129 {
4130 if(isCuttableNextType(type))
4131 {
4132 s->data[i]++;
4133 }
4134 else
4135 {
4136 s->data[i] = s->undercombo;
4137 s->cset[i] = s->undercset;
4138 s->sflag[i] = 0;
4139 }
4140 }
4141
4142
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1769698 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1769698 times.
1769699 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4143 {
4144
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4145 {
4146 4 findentrance(bx,by,mfSWORD+i2,true);
4147 4 }
4148
4149 1 findentrance(fx,fy,mfSTRIKE,true);
4150 1 }
4151
1/2
✓ Branch 0 taken 1769698 times.
✗ Branch 1 not taken.
1769698 else if(!ignoreffc)
4152 {
4153 if(isCuttableNextType(type2))
4154 {
4155 zc_ffc_modify(s->ffcs[current_ffcombo], 1);
4156 }
4157 else
4158 {
4159 zc_ffc_set(s->ffcs[current_ffcombo], s->undercombo);
4160 s->ffcs[current_ffcombo].cset = s->undercset;
4161 }
4162 }
4163
4164
2/2
✓ Branch 0 taken 1753130 times.
✓ Branch 1 taken 16569 times.
1769699 if(!ignorescreen)
4165 {
4166
4/4
✓ Branch 0 taken 5433 times.
✓ Branch 1 taken 11136 times.
✓ Branch 2 taken 290 times.
✓ Branch 3 taken 5143 times.
16569 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
4167
4168
8/8
✓ Branch 0 taken 16264 times.
✓ Branch 1 taken 305 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 16309 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 305 times.
✓ Branch 6 taken 45 times.
✓ Branch 7 taken 215 times.
16569 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4169 {
4170
4/8
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 260 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 260 times.
✗ Branch 7 not taken.
260 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4171 260 sfx(tmpscr->secretsfx);
4172 260 }
4173
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 15889 times.
16309 else if(isCuttableItemType(type))
4174 {
4175 15889 int32_t it = -1;
4176 15889 int32_t thedropset = -1;
4177
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 15841 times.
15889 if ( (cmb.usrflags&cflag2) ) //specific dropset or item
4178 {
4179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if ( cmb.usrflags&cflag11 )
4180 {
4181 it = cmb.attribytes[1];
4182 }
4183 else
4184 {
4185 48 it = select_dropitem(cmb.attribytes[1]);
4186 48 thedropset = cmb.attribytes[1];
4187 }
4188 48 }
4189 else
4190 {
4191 15841 it = select_dropitem(12);
4192 15841 thedropset = 12;
4193 }
4194
4195
2/2
✓ Branch 0 taken 11114 times.
✓ Branch 1 taken 4775 times.
15889 if(it!=-1)
4196 {
4197
4/8
✓ Branch 0 taken 4775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4775 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4775 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4775 times.
✗ Branch 7 not taken.
4775 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4198 4775 itm->from_dropset = thedropset;
4199 4775 items.add(itm);
4200 4775 }
4201 15889 }
4202
4203 16569 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4204
4205
2/2
✓ Branch 0 taken 8270 times.
✓ Branch 1 taken 8299 times.
16569 if(get_qr(qr_MORESOUNDS))
4206 {
4207
6/6
✓ Branch 0 taken 6765 times.
✓ Branch 1 taken 1534 times.
✓ Branch 2 taken 4720 times.
✓ Branch 3 taken 2045 times.
✓ Branch 4 taken 4095 times.
✓ Branch 5 taken 625 times.
8299 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4208 {
4209
2/2
✓ Branch 0 taken 581 times.
✓ Branch 1 taken 44 times.
625 if (cmb.usrflags&cflag3)
4210 {
4211 44 sfx(cmb.attribytes[2],int32_t(bx));
4212 44 }
4213 625 }
4214 else
4215 {
4216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7674 times.
7674 if (cmb.usrflags&cflag3)
4217 {
4218 sfx(cmb.attribytes[2],int32_t(bx));
4219 }
4220 7674 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4221 }
4222 8299 }
4223
4224 16569 spawn_decoration_xy(cmb, fx, fy);
4225 16569 }
4226
4227
2/2
✓ Branch 0 taken 1769698 times.
✓ Branch 1 taken 1 times.
1769699 if(!ignoreffc)
4228 {
4229
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4230
4231
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(isCuttableItemType(type2))
4232 {
4233 int32_t it=-1;
4234 int32_t thedropset=-1;
4235 if ( (cmb_ff.usrflags&cflag2) )
4236 {
4237 if(cmb_ff.usrflags&cflag11)
4238 it = cmb_ff.attribytes[1];
4239 else
4240 {
4241 it = select_dropitem(cmb_ff.attribytes[1]);
4242 thedropset = cmb_ff.attribytes[1];
4243 }
4244 }
4245 else
4246 {
4247 if(get_qr(qr_HARDCODED_FFC_BUSH_DROPS))
4248 {
4249 int32_t r=zc_oldrand()%100;
4250
4251 if(r<15)
4252 it=iHeart; // 15%
4253 else if(r<35)
4254 it=iRupy; // 20%
4255 }
4256 else
4257 {
4258 it = select_dropitem(12);
4259 thedropset = 12;
4260 }
4261 }
4262
4263 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4264 {
4265 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4266 itm->from_dropset = thedropset;
4267 items.add(itm);
4268 }
4269 }
4270
4271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_qr(qr_MORESOUNDS))
4272 {
4273
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4274 {
4275
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (cmb_ff.usrflags&cflag3)
4276 {
4277 sfx(cmb_ff.attribytes[2],int32_t(bx));
4278 }
4279 1 }
4280 else
4281 {
4282 if (cmb_ff.usrflags&cflag3)
4283 {
4284 sfx(cmb_ff.attribytes[2],int32_t(bx));
4285 }
4286 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4287 }
4288 1 }
4289
4290 1 spawn_decoration_xy(cmb_ff, fx, fy);
4291 1 }
4292 1865048 }
4293
4294 25010220 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4295 {
4296 /*
4297 int32_t par_item = w->parentitem;
4298 al_trace("check_wpn_triggers(weapon *w): par_item is: %d\n", par_item);
4299 int32_t usewpn = -1;
4300 if ( par_item > -1 )
4301 {
4302 usewpn = itemsbuf[par_item].useweapon;
4303 }
4304 else if ( par_item == -1 && w->ScriptGenerated )
4305 {
4306 usewpn = w->useweapon;
4307 }
4308 al_trace("check_wpn_triggers(weapon *w): usewpn is: %d\n", usewpn);
4309
4310 */
4311 25010220 bx=vbound(bx, 0, 255);
4312 25010220 by=vbound(by, 0, 176);
4313 25010220 int32_t cid = MAPCOMBO(bx,by);
4314
4/30
✓ Branch 0 taken 3120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 201384 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 24801052 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4664 times.
✗ Branch 29 not taken.
25010220 switch(w->useweapon)
4315 {
4316 case wArrow:
4317 3120 findentrance(bx,by,mfARROW,true);
4318 3120 findentrance(bx,by,mfSARROW,true);
4319 3120 findentrance(bx,by,mfGARROW,true);
4320 3120 break;
4321 case wBeam:
4322 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4323 break;
4324 case wHookshot:
4325 findentrance(bx,by,mfHOOKSHOT,true);
4326 break;
4327 case wBrang:
4328 for(int32_t i = 0; i <3; i++) findentrance(bx,by,mfBRANG+i,true);
4329 break;
4330 case wMagic:
4331 findentrance(bx,by,mfWANDMAGIC,true);
4332 break;
4333 case wRefMagic:
4334 findentrance(bx,by,mfWANDMAGIC,true);
4335 break;
4336 case wRefBeam:
4337 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4338 break;
4339 //reflected magic needs to happen in mirrors:
4340 //
4341 //findentrance(bx,by,mfREFMAGIC,true)
4342 case wRefFireball:
4343 findentrance(bx,by,mfREFFIREBALL,true);
4344 break;
4345 case wBomb:
4346 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4347 break;
4348
4349 case wSBomb:
4350 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4351 break;
4352
4353 case wFire:
4354 201384 findentrance(bx,by,mfANYFIRE,true);
4355 201384 findentrance(bx,by,mfSTRONGFIRE,true);
4356 201384 findentrance(bx,by,mfMAGICFIRE,true);
4357 /* if we want the weapon to die
4358 if (findentrance(bx,by,mfANYFIRE,true) ) dead = 1;
4359 if (findentrance(bx,by,mfSTRONGFIRE,true) ) dead = 1;
4360 if (findentrance(bx,by,mfMAGICFIRE,true)) dead = 1;
4361 */
4362 201384 break;
4363
4364 case wScript1:
4365 break;
4366 case wScript2:
4367 break;
4368 case wScript3:
4369 break;
4370 case wScript4:
4371 break;
4372 case wScript5:
4373 break;
4374 case wScript6:
4375 break;
4376 case wScript7:
4377 break;
4378 case wScript8:
4379 break;
4380 case wScript9:
4381 break;
4382 case wScript10:
4383 break;
4384 case wIce:
4385 break;
4386 case wCByrna:
4387 break;
4388 case wWhistle:
4389 break;
4390 case wSSparkle:
4391 case wFSparkle:
4392 break;
4393 case wWind:
4394 break;
4395 case wBait:
4396 break;
4397 case wFlame:
4398 case wThrown:
4399 case wBombos:
4400 case wEther:
4401 case wQuake:
4402 case wSwordLA:
4403 case wSword180:
4404 case wStomp:
4405 break;
4406 case wSword:
4407 case wWand:
4408 //case wCandle:
4409 case wHSHandle:
4410 case wLitBomb:
4411 case wLitSBomb:
4412 4664 break;
4413 24801052 default: break;
4414
4415 }
4416 25010220 }
4417
4418 50020440 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4419 {
4420
4421
2/2
✓ Branch 0 taken 1937866 times.
✓ Branch 1 taken 48082574 times.
50020440 if(!(get_qr(qr_BUSHESONLAYERS1AND2)))
4422 {
4423 //zprint("bit off\n");
4424 48082574 return;
4425 }
4426 //keep things inside the screen boundaries
4427 1937866 bx=vbound(bx, 0, 255);
4428 1937866 by=vbound(by, 0, 176);
4429 1937866 int32_t fx=vbound(bx, 0, 255);
4430 1937866 int32_t fy=vbound(by, 0, 176);
4431 //first things first
4432
2/2
✓ Branch 0 taken 1931034 times.
✓ Branch 1 taken 6832 times.
1937866 if(w->useweapon != wSword)
4433 1931034 return;
4434
4435 //find out which combo row/column the coordinates are in
4436 6832 bx &= 0xF0;
4437 6832 by &= 0xF0;
4438
4439
4440 6832 int32_t flag = MAPFLAGL(layer,bx,by);
4441 6832 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4442 6832 int32_t cid = MAPCOMBOL(layer,bx,by);
4443 6832 int32_t type = combobuf[cid].type;
4444
1/2
✓ Branch 0 taken 6832 times.
✗ Branch 1 not taken.
6832 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4445 type = cNONE;
4446 //zprint("cid is: %d\n", cid);
4447 //zprint("type is: %d\n", type);
4448 6832 int32_t i = (bx>>4) + by;
4449
4450
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 6448 times.
6832 if(i > 175)
4451 384 return;
4452
4453
4/4
✓ Branch 0 taken 6436 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 6430 times.
✓ Branch 3 taken 6 times.
6448 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4454 {
4455 6442 return;
4456 //ignorescreen = true;
4457 //zprint("ignoring\n");
4458 }
4459
4460
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4461
4462 {
4463
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4464
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(isCuttableNextType(type) || isCuttableNextType(type))
4465 {
4466 6 FFCore.tempScreens[layer]->data[i]++;
4467 6 }
4468 else
4469 {
4470 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
4471 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
4472 FFCore.tempScreens[layer]->sflag[i] = 0;
4473 }
4474
2/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4475 {
4476 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4477 sfx(tmpscr->secretsfx);
4478 }
4479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(isCuttableItemType(type))
4480 {
4481 6 int32_t it = -1;
4482 6 int32_t thedropset = -1;
4483
4484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( (combobuf[cid].usrflags&cflag2) )
4485 {
4486 if(combobuf[cid].usrflags&cflag11)
4487 it = combobuf[cid].attribytes[1];
4488 else
4489 {
4490 it = select_dropitem(combobuf[cid].attribytes[1]);
4491 thedropset = combobuf[cid].attribytes[1];
4492 }
4493 }
4494 else
4495 {
4496 6 it = select_dropitem(12);
4497 6 thedropset = 12;
4498 }
4499
4500
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if(it!=-1)
4501 {
4502
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
2 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4503 2 itm->from_dropset = thedropset;
4504 2 items.add(itm);
4505 2 }
4506 6 }
4507
4508 6 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
4509
4510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(get_qr(qr_MORESOUNDS))
4511 {
4512
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4513 {
4514 if (combobuf[cid].usrflags&cflag3)
4515 {
4516 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4517 }
4518 }
4519 else
4520 {
4521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (combobuf[cid].usrflags&cflag3)
4522 {
4523 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4524 }
4525 6 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4526 }
4527 6 }
4528
4529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4530
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(decotype > 3) decotype = 0;
4531
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4532
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 switch(decotype)
4533 {
4534 case -2: break; //nothing
4535 case -1:
4536 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4537 break;
4538
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4539 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4540 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4541 }
4542
4543 }
4544
4545 50020440 }
4546
4547 25010330 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4548 {
4549 /*
4550 int32_t par_item = w->parentitem;
4551 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4552 int32_t usewpn = -1;
4553 if ( par_item > -1 )
4554 {
4555 usewpn = itemsbuf[par_item].useweapon;
4556 }
4557 else if ( par_item == -1 && w->ScriptGenerated )
4558 {
4559 usewpn = w->useweapon;
4560 }
4561 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4562 */
4563
4564
4565 //keep things inside the screen boundaries
4566 25010330 bx=vbound(bx, 0, 255);
4567 25010330 by=vbound(by, 0, 176);
4568 25010330 int32_t fx=vbound(bx, 0, 255);
4569 25010330 int32_t fy=vbound(by, 0, 176);
4570 25010330 int32_t cid = MAPCOMBO(bx,by);
4571
4572 //find out which combo row/column the coordinates are in
4573 25010330 bx &= 0xF0;
4574 25010330 by &= 0xF0;
4575
4576 25010330 int32_t type = COMBOTYPE(bx,by);
4577 25010330 int32_t type2 = FFCOMBOTYPE(fx,fy);
4578 25010330 int32_t flag = MAPFLAG(bx,by);
4579 25010330 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4580 25010330 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4581
2/2
✓ Branch 0 taken 25010116 times.
✓ Branch 1 taken 214 times.
25010330 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4582 214 type = cNONE;
4583 25010330 byte dontignore = 0;
4584 25010330 byte dontignoreffc = 0;
4585
4586
4/4
✓ Branch 0 taken 428054 times.
✓ Branch 1 taken 24582276 times.
✓ Branch 2 taken 427456 times.
✓ Branch 3 taken 598 times.
25010330 if (isCuttableType(type) && MatchComboTrigger(w, combobuf.data(), cid))
4587 {
4588 598 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4589 598 dontignore = 1;
4590 598 }
4591
4592 /*to-do, ffcs
4593 if (isCuttableType(type2) && MatchComboTrigger(w, combobuf, cid))
4594 {
4595 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4596 dontignoreffc = 1;
4597 }*/
4598
4/4
✓ Branch 0 taken 25005556 times.
✓ Branch 1 taken 4774 times.
✓ Branch 2 taken 25004958 times.
✓ Branch 3 taken 598 times.
25010330 if(w->useweapon != wSword && !dontignore) return;
4599
4600
4601 5372 int32_t i = (bx>>4) + by;
4602
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5351 times.
5372 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4603
4604
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 5159 times.
5351 if(i > 175)
4605 192 return;
4606
4607 5159 bool ignorescreen=false;
4608 5159 bool ignoreffc=false;
4609
4610
1/2
✓ Branch 0 taken 5159 times.
✗ Branch 1 not taken.
5159 if(get_bit(w->wscreengrid, i) != 0)
4611 {
4612 ignorescreen = true; dontignore = 0;
4613 }
4614
4615 5159 int32_t current_ffcombo = getFFCAt(fx,fy);
4616
4617
3/4
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 4893 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266 times.
5159 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4618 {
4619 4893 ignoreffc = true;
4620 4893 }
4621
1/2
✓ Branch 0 taken 266 times.
✗ Branch 1 not taken.
266 else if(combobuf[tmpscr->ffcs[current_ffcombo].data].triggerflags[0] & combotriggerONLYGENTRIG)
4622 type2 = cNONE;
4623
3/4
✓ Branch 0 taken 4439 times.
✓ Branch 1 taken 720 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4439 times.
9598 if(!isCuttableType(type) &&
4624
5/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 4339 times.
✓ Branch 2 taken 4439 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 718 times.
✓ Branch 5 taken 3721 times.
4439 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4625 {
4626 4439 ignorescreen = true;
4627 4439 }
4628
4629
3/4
✓ Branch 0 taken 5049 times.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5049 times.
10208 if(!isCuttableType(type2) &&
4630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5049 times.
5049 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4631 {
4632 5049 ignoreffc = true;
4633 5049 }
4634
4635 5159 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4636
4637
4/4
✓ Branch 0 taken 4659 times.
✓ Branch 1 taken 316 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 4426 times.
5159 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4638 4975 byte skipsecrets = 0;
4639
2/2
✓ Branch 0 taken 4438 times.
✓ Branch 1 taken 501 times.
4975 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4640 {
4641
2/2
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 3 times.
501 if (get_qr(qr_OLD_SLASHNEXT_SECRETS))
4642 {
4643 498 skipsecrets = 0;
4644 498 }
4645 3 else skipsecrets = 1;
4646 501 }
4647
6/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4936 times.
✓ Branch 2 taken 4439 times.
✓ Branch 3 taken 4436 times.
✓ Branch 4 taken 4439 times.
✓ Branch 5 taken 4933 times.
4939 if((!skipsecrets || !get_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4648 {
4649
3/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 608 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9372 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4650 {
4651 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4652 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4653 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4654 }
4655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 else if(flag == mfARMOS_SECRET)
4656 {
4657 s->data[i] = s->secretcombo[sSTAIRS];
4658 s->cset[i] = s->secretcset[sSTAIRS];
4659 s->sflag[i] = s->secretflag[sSTAIRS];
4660 sfx(tmpscr->secretsfx);
4661 }
4662
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
610 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4663 {
4664 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4665 {
4666 findentrance(bx,by,mfSWORD+i2,true);
4667 }
4668
4669 findentrance(bx,by,mfSTRIKE,true);
4670 }
4671
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
610 else if(((flag2 >= 16)&&(flag2 <= 31)))
4672 {
4673 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4674 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4675 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4676 }
4677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 else if(flag2 == mfARMOS_SECRET)
4678 {
4679 s->data[i] = s->secretcombo[sSTAIRS];
4680 s->cset[i] = s->secretcset[sSTAIRS];
4681 s->sflag[i] = s->secretflag[sSTAIRS];
4682 sfx(tmpscr->secretsfx);
4683 }
4684
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
610 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4685 {
4686 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4687 {
4688 findentrance(bx,by,mfSWORD+i2,true);
4689 }
4690
4691 findentrance(bx,by,mfSTRIKE,true);
4692 }
4693 else
4694 {
4695
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 109 times.
610 if(isCuttableNextType(type))
4696 {
4697 501 s->data[i]++;
4698 501 }
4699 else
4700 {
4701 109 s->data[i] = s->undercombo;
4702 109 s->cset[i] = s->undercset;
4703 109 s->sflag[i] = 0;
4704 }
4705
4706 //pausenow=true;
4707 }
4708 610 }
4709
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4439 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4439 else if(skipsecrets && (!ignorescreen || dontignore))
4710 {
4711 if(isCuttableNextType(type))
4712 {
4713 s->data[i]++;
4714 }
4715 else
4716 {
4717 s->data[i] = s->undercombo;
4718 s->cset[i] = s->undercset;
4719 s->sflag[i] = 0;
4720 }
4721 }
4722
4723
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5049 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5049 times.
5049 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4724 {
4725 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4726 {
4727 findentrance(bx,by,mfSWORD+i2,true);
4728 }
4729
4730 findentrance(fx,fy,mfSTRIKE,true);
4731 }
4732
1/2
✓ Branch 0 taken 5049 times.
✗ Branch 1 not taken.
5049 else if(!ignoreffc)
4733 {
4734 if(isCuttableNextType(type2))
4735 {
4736 zc_ffc_modify(s->ffcs[current_ffcombo], 1);
4737 }
4738 else
4739 {
4740 zc_ffc_set(s->ffcs[current_ffcombo], s->undercombo);
4741 s->ffcs[current_ffcombo].cset = s->undercset;
4742 }
4743 }
4744
4745
3/4
✓ Branch 0 taken 4439 times.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4439 times.
5049 if(!ignorescreen || dontignore)
4746 {
4747
3/4
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 425 times.
610 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4748
4749
2/8
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
610 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4750 {
4751 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4752 sfx(tmpscr->secretsfx);
4753 }
4754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 else if(isCuttableItemType(type))
4755 {
4756 610 int32_t it = -1;
4757 610 int32_t thedropset = -1;
4758
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 601 times.
610 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4759 {
4760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if ( combobuf[cid].usrflags&cflag11 )
4761 {
4762 it = combobuf[cid].attribytes[1];
4763 }
4764 else
4765 {
4766 9 it = select_dropitem(combobuf[cid].attribytes[1]);
4767 9 thedropset = combobuf[cid].attribytes[1];
4768 }
4769 9 }
4770 else
4771 {
4772 601 it = select_dropitem(12);
4773 601 thedropset = 12;
4774 }
4775
4776
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 198 times.
610 if(it!=-1)
4777 {
4778
4/8
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 198 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 198 times.
✗ Branch 7 not taken.
198 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4779 198 itm->from_dropset = thedropset;
4780 198 items.add(itm);
4781 198 }
4782 610 }
4783
4784
4785 610 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4786
4787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(get_qr(qr_MORESOUNDS))
4788 {
4789
5/6
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 100 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
610 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4790 {
4791 if (combobuf[cid].usrflags&cflag3)
4792 {
4793 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4794 }
4795 }
4796 else
4797 {
4798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if (combobuf[cid].usrflags&cflag3)
4799 {
4800 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4801 }
4802 610 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4803 }
4804 610 }
4805
4806
3/4
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 598 times.
✗ Branch 3 not taken.
610 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4807
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(decotype > 3) decotype = 0;
4808
6/8
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
610 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4809
3/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 501 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 9 times.
610 switch(decotype)
4810 {
4811 case -2: break; //nothing
4812 case -1:
4813 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4814 break;
4815
3/6
✓ Branch 0 taken 501 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 501 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 501 times.
✗ Branch 5 not taken.
501 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4816
3/6
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
100 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4817
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4818 }
4819 610 }
4820
4821
1/2
✓ Branch 0 taken 5049 times.
✗ Branch 1 not taken.
5049 if(!ignoreffc)
4822 {
4823 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4824
4825 if(isCuttableItemType(type2))
4826 {
4827 int32_t it=-1;
4828 int32_t thedropset=-1;
4829 if ( (combobuf[cid].usrflags&cflag2) )
4830 {
4831 if(combobuf[cid].usrflags&cflag11)
4832 it = combobuf[cid].attribytes[1];
4833 else
4834 {
4835 it = select_dropitem(combobuf[cid].attribytes[1]);
4836 thedropset = combobuf[cid].attribytes[1];
4837 }
4838 }
4839 else
4840 {
4841 int32_t r=zc_oldrand()%100;
4842
4843 if(r<15)
4844 {
4845 it=iHeart; // 15%
4846 }
4847 else if(r<35)
4848 {
4849 it=iRupy; // 20%
4850 }
4851 }
4852
4853 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4854 {
4855 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4856 itm->from_dropset = thedropset;
4857 items.add(itm);
4858 }
4859 }
4860
4861 if(get_qr(qr_MORESOUNDS))
4862 {
4863 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4864 {
4865 if (combobuf[cid].usrflags&cflag3)
4866 {
4867 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4868 }
4869 }
4870 else
4871 {
4872 if (combobuf[cid].usrflags&cflag3)
4873 {
4874 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4875 }
4876 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4877 }
4878 }
4879
4880 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4881 if(decotype > 3) decotype = 0;
4882 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4883 switch(decotype)
4884 {
4885 case -2: break; //nothing
4886 case -1:
4887 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4888 break;
4889 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4890 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4891 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4892 }
4893 }
4894 25010220 }
4895
4896 25010220 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4897 {
4898 /*
4899 int32_t par_item = w->parentitem;
4900 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
4901 int32_t usewpn = -1;
4902 if ( par_item > -1 )
4903 {
4904 usewpn = itemsbuf[par_item].useweapon;
4905 }
4906 else if ( par_item == -1 && w->ScriptGenerated )
4907 {
4908 usewpn = w->useweapon;
4909 }
4910 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
4911 */
4912
4913 25010220 byte dontignore = 0;
4914 25010220 byte dontignoreffc = 0;
4915
4916
4917
4918
4919
4920 //keep things inside the screen boundaries
4921 25010220 bx=vbound(bx, 0, 255);
4922 25010220 by=vbound(by, 0, 176);
4923 25010220 int32_t fx=vbound(bx, 0, 255);
4924 25010220 int32_t fy=vbound(by, 0, 176);
4925 25010220 int32_t cid = MAPCOMBO(bx,by);
4926
4927 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4928
3/4
✓ Branch 0 taken 25010220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2588 times.
✓ Branch 3 taken 25007632 times.
25010220 if(w->useweapon != wWand && !MatchComboTrigger (w, combobuf.data(), cid)) return;
4929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2588 times.
2588 if ( MatchComboTrigger (w, combobuf.data(), cid) ) dontignore = 1;
4930
4931 //first things first
4932
2/4
✓ Branch 0 taken 2588 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2588 times.
2588 if(z>8||fakez>8) return;
4933
4934 //find out which combo row/column the coordinates are in
4935 2588 bx &= 0xF0;
4936 2588 by &= 0xF0;
4937
4938 2588 int32_t flag = MAPFLAG(bx,by);
4939 2588 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4940 2588 int32_t flag3=0;
4941 2588 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4942 2588 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4943 2588 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4944 2588 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4945
4946
4/8
✓ Branch 0 taken 2588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2588 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2588 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2588 times.
2588 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4947 flag3=mfWAND;
4948
4949
4/8
✓ Branch 0 taken 2588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2588 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2588 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2588 times.
2588 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4950 flag3=mfSTRIKE;
4951
4952 2588 int32_t i = (bx>>4) + by;
4953
4954
6/12
✓ Branch 0 taken 2588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2588 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2588 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2588 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2588 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2588 times.
2588 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4955 2588 return;
4956
4957 if(i > 175)
4958 return;
4959
4960 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4961
4962 //findentrance(bx,by,mfWAND,true);
4963 //findentrance(bx,by,mfSTRIKE,true);
4964 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
4965 {
4966 if(flag3==mfWAND||flag3==mfSTRIKE)
4967 {
4968 findentrance(fx,fy,mfWAND,true);
4969 findentrance(fx,fy,mfSTRIKE,true);
4970 }
4971 }
4972
4973 if(dontignore) { findentrance(bx,by,mfWAND,true); }
4974
4975 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4976 25010220 }
4977
4978 void HeroClass::check_slash_block(weapon *w)
4979 {
4980 //first things
4981
4982 int32_t par_item = w->parentitem;
4983 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4984 int32_t usewpn = -1;
4985 if ( par_item > -1 )
4986 {
4987 usewpn = itemsbuf[par_item].useweapon;
4988 }
4989 else if ( par_item == -1 && w->ScriptGenerated )
4990 {
4991 usewpn = w->useweapon;
4992 }
4993 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4994 if(usewpn != wSword) return;
4995
4996
4997 int32_t bx = 0, by = 0;
4998 bx = ((int32_t)w->x) + (((int32_t)w->hit_width)/2);
4999 by = ((int32_t)w->y) + (((int32_t)w->hit_height)/2);
5000 al_trace("check_slash_block(weapon *w): bx is: %d\n", bx);
5001 al_trace("check_slash_block(weapon *w): by is: %d\n", by);
5002 //keep things inside the screen boundaries
5003 bx=vbound(bx, 0, 255);
5004 by=vbound(by, 0, 176);
5005 int32_t fx=vbound(bx, 0, 255);
5006 int32_t fy=vbound(by, 0, 176);
5007
5008 int32_t cid = MAPCOMBO(bx,by);
5009
5010 //find out which combo row/column the coordinates are in
5011 bx &= 0xF0;
5012 by &= 0xF0;
5013
5014 int32_t type = COMBOTYPE(bx,by);
5015 int32_t type2 = FFCOMBOTYPE(fx,fy);
5016 int32_t flag = MAPFLAG(bx,by);
5017 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5018 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5019 int32_t i = (bx>>4) + by;
5020
5021 if(i > 175)
5022 {
5023 al_trace("check_slash_block(weapon *w): %s\n", "i > 175");
5024 return;
5025 }
5026
5027 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
5028 type = cNONE;
5029 bool ignorescreen=false;
5030 bool ignoreffc=false;
5031
5032 if(get_bit(screengrid, i) != 0)
5033 {
5034 ignorescreen = true;
5035 }
5036
5037 int32_t current_ffcombo = getFFCAt(fx,fy);
5038
5039 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5040 {
5041 ignoreffc = true;
5042 }
5043 else if(combobuf[tmpscr->ffcs[current_ffcombo].data].triggerflags[0] & combotriggerONLYGENTRIG)
5044 type2 = cNONE;
5045 if(!isCuttableType(type) &&
5046 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
5047 {
5048 ignorescreen = true;
5049 }
5050
5051 if(!isCuttableType(type2) &&
5052 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
5053 {
5054 ignoreffc = true;
5055 }
5056
5057 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5058
5059 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
5060
5061 if(!ignorescreen)
5062 {
5063 if((flag >= 16)&&(flag <= 31))
5064 {
5065 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5066 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5067 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5068 }
5069 else if(flag == mfARMOS_SECRET)
5070 {
5071 s->data[i] = s->secretcombo[sSTAIRS];
5072 s->cset[i] = s->secretcset[sSTAIRS];
5073 s->sflag[i] = s->secretflag[sSTAIRS];
5074 sfx(tmpscr->secretsfx);
5075 }
5076 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
5077 {
5078 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5079 {
5080 findentrance(bx,by,mfSWORD+i2,true);
5081 }
5082
5083 findentrance(bx,by,mfSTRIKE,true);
5084 }
5085 else if(((flag2 >= 16)&&(flag2 <= 31)))
5086 {
5087 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5088 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5089 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5090 }
5091 else if(flag2 == mfARMOS_SECRET)
5092 {
5093 s->data[i] = s->secretcombo[sSTAIRS];
5094 s->cset[i] = s->secretcset[sSTAIRS];
5095 s->sflag[i] = s->secretflag[sSTAIRS];
5096 sfx(tmpscr->secretsfx);
5097 }
5098 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
5099 {
5100 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5101 {
5102 findentrance(bx,by,mfSWORD+i2,true);
5103 }
5104
5105 findentrance(bx,by,mfSTRIKE,true);
5106 }
5107 else
5108 {
5109 if(isCuttableNextType(type))
5110 {
5111 s->data[i]++;
5112 }
5113 else
5114 {
5115 s->data[i] = s->undercombo;
5116 s->cset[i] = s->undercset;
5117 s->sflag[i] = 0;
5118 }
5119
5120 //pausenow=true;
5121 }
5122 }
5123
5124 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
5125 {
5126 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5127 {
5128 findentrance(bx,by,mfSWORD+i2,true);
5129 }
5130
5131 findentrance(fx,fy,mfSTRIKE,true);
5132 }
5133 else if(!ignoreffc)
5134 {
5135 if(isCuttableNextType(type2))
5136 {
5137 zc_ffc_modify(s->ffcs[current_ffcombo], 1);
5138 }
5139 else
5140 {
5141 zc_ffc_set(s->ffcs[current_ffcombo], s->undercombo);
5142 s->ffcs[current_ffcombo].cset = s->undercset;
5143 }
5144 }
5145
5146 if(!ignorescreen)
5147 {
5148 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
5149
5150 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5151 {
5152 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5153 sfx(tmpscr->secretsfx);
5154 }
5155 else if(isCuttableItemType(type))
5156 {
5157 int32_t it = -1;
5158 int32_t thedropset = -1;
5159 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5160 {
5161 if ( combobuf[cid].usrflags&cflag11 )
5162 {
5163 it = combobuf[cid].attribytes[1];
5164 }
5165 else
5166 {
5167 it = select_dropitem(combobuf[cid].attribytes[1]);
5168 thedropset = combobuf[cid].attribytes[1];
5169 }
5170 }
5171 else
5172 {
5173 it = select_dropitem(12);
5174 thedropset = 12;
5175 }
5176
5177 if(it!=-1)
5178 {
5179 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5180 itm->from_dropset = thedropset;
5181 items.add(itm);
5182 }
5183 }
5184
5185 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5186
5187 if(get_qr(qr_MORESOUNDS))
5188 {
5189 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5190 {
5191 if (combobuf[cid].usrflags&cflag3)
5192 {
5193 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5194 }
5195 }
5196 else
5197 {
5198 if (combobuf[cid].usrflags&cflag3)
5199 {
5200 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5201 }
5202 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5203 }
5204 }
5205
5206 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5207 if(decotype > 3) decotype = 0;
5208 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5209 switch(decotype)
5210 {
5211 case -2: break; //nothing
5212 case -1:
5213 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
5214 break;
5215 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5216 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5217 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5218 }
5219 }
5220
5221 if(!ignoreffc)
5222 {
5223 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
5224
5225 if(isCuttableItemType(type2))
5226 {
5227 int32_t it=-1;
5228 int32_t thedropset = -1;
5229 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5230 {
5231 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5232 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5233 else
5234 {
5235 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5236 it = select_dropitem(thedropset);
5237 }
5238 }
5239 else
5240 {
5241 it = select_dropitem(12);
5242 thedropset = 12;
5243 }
5244
5245 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5246 {
5247 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5248 itm->from_dropset = thedropset;
5249 items.add(itm);
5250 }
5251 }
5252
5253 if(get_qr(qr_MORESOUNDS))
5254 {
5255 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5256 {
5257 if (combobuf[cid].usrflags&cflag3)
5258 {
5259 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5260 }
5261 }
5262 else
5263 {
5264 if (combobuf[cid].usrflags&cflag3)
5265 {
5266 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5267 }
5268 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5269 }
5270 }
5271
5272 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5273 if(decotype > 3) decotype = 0;
5274 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5275 switch(decotype)
5276 {
5277 case -2: break; //nothing
5278 case -1:
5279 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
5280 break;
5281 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5282 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5283 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5284 }
5285 }
5286 }
5287
5288 //TODO: Boomerang that cuts bushes. -L
5289 /*void HeroClass::slash_bush()
5290 {
5291
5292 }*/
5293
5294 38240 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5295 {
5296 //keep things inside the screen boundaries
5297 38240 bx=vbound(bx, 0, 255);
5298 38240 by=vbound(by, 0, 176);
5299 38240 int32_t fx=vbound(bx, 0, 255);
5300 38240 int32_t fy=vbound(by, 0, 176);
5301 38240 int32_t cid = MAPCOMBO(bx,by);
5302
5303 //first things first
5304
2/4
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38240 times.
38240 if(z>8||fakez>8) return;
5305
5306 //find out which combo row/column the coordinates are in
5307 38240 bx &= 0xF0;
5308 38240 by &= 0xF0;
5309
5310 38240 int32_t flag = MAPFLAG(bx,by);
5311 38240 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5312 38240 int32_t flag3=0;
5313 38240 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5314 38240 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5315 38240 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5316 38240 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5317
5318
4/8
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38240 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 38240 times.
38240 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5319 flag3=mfWAND;
5320
5321
4/8
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38240 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 38240 times.
38240 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5322 flag3=mfSTRIKE;
5323
5324 38240 int32_t i = (bx>>4) + by;
5325
5326
7/12
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 38239 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 38239 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 38239 times.
✗ Branch 11 not taken.
38240 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5327 38239 return;
5328
5329
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(i > 175)
5330 return;
5331
5332 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5333
5334 //findentrance(bx,by,mfWAND,true);
5335 //findentrance(bx,by,mfSTRIKE,true);
5336
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5337 {
5338 if(flag3==mfWAND||flag3==mfSTRIKE)
5339 {
5340 findentrance(fx,fy,mfWAND,true);
5341 findentrance(fx,fy,mfSTRIKE,true);
5342 }
5343 }
5344
5345 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5346 38240 }
5347
5348 5120 void HeroClass::check_pound_block(int bx, int by, weapon* w)
5349 {
5350
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5120 if(w && w->no_triggers()) return;
5351
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5120 if(w && w->id == wHammer && getHammerState() < 3)
5352 return;
5353
1/2
✓ Branch 0 taken 5120 times.
✗ Branch 1 not taken.
5120 if(get_qr(qr_POUNDLAYERS1AND2))
5354 {
5355 check_pound_block_layer(bx,by,1,w);
5356 check_pound_block_layer(bx,by,2,w);
5357 }
5358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5120 times.
5120 auto* grid = w ? w->wscreengrid : screengrid;
5359 //keep things inside the screen boundaries
5360 5120 bx=vbound(bx, 0, 255);
5361 5120 by=vbound(by, 0, 176);
5362 5120 int32_t fx=vbound(bx, 0, 255);
5363 5120 int32_t fy=vbound(by, 0, 176);
5364 5120 int32_t cid = MAPCOMBO(bx,by);
5365
5366 //first things first
5367
2/4
✓ Branch 0 taken 5120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5120 times.
5120 if(z>8||fakez>8) return;
5368
5369 //find out which combo row/column the coordinates are in
5370 5120 bx &= 0xF0;
5371 5120 by &= 0xF0;
5372
5373 5120 int32_t type = COMBOTYPE(bx,by);
5374 5120 int32_t type2 = FFCOMBOTYPE(fx,fy);
5375 5120 int32_t flag = MAPFLAG(bx,by);
5376 5120 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5377 5120 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5378 5120 int32_t i = (bx>>4) + by;
5379
5380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5120 times.
5120 if(i > 175)
5381 return;
5382
5383 5120 bool ignorescreen=false;
5384 5120 bool ignoreffc=false;
5385 5120 bool pound=false;
5386
5387
9/10
✓ Branch 0 taken 4436 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 4426 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 4426 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4424 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 4422 times.
5120 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5388 4422 ignorescreen = true; // Affect only FFCs
5389
5390
2/2
✓ Branch 0 taken 4664 times.
✓ Branch 1 taken 456 times.
5120 if(get_bit(grid, i) != 0)
5391 456 ignorescreen = true;
5392
5393 5120 int32_t current_ffcombo = getFFCAt(fx,fy);
5394
5395
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 5081 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
5120 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5396 5081 ignoreffc = true;
5397
5398
3/6
✓ Branch 0 taken 5120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5120 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5120 times.
5120 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5399 5120 ignoreffc = true;
5400
5401
3/4
✓ Branch 0 taken 4593 times.
✓ Branch 1 taken 527 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4593 times.
5120 if(ignorescreen && ignoreffc) // Nothing to do.
5402 4593 return;
5403
5404 527 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5405
5406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if(!ignorescreen)
5407 {
5408
3/4
✓ Branch 0 taken 499 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 499 times.
527 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5409 {
5410 28 findentrance(bx,by,mfHAMMER,true);
5411 28 findentrance(bx,by,mfSTRIKE,true);
5412 28 }
5413
3/4
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 497 times.
499 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5414 {
5415 2 findentrance(bx,by,mfHAMMER,true);
5416 2 findentrance(bx,by,mfSTRIKE,true);
5417 2 }
5418
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 492 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
497 else if((flag >= 16)&&(flag <= 31))
5419 {
5420 5 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5421 5 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5422 5 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5423 5 }
5424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 else if(flag == mfARMOS_SECRET)
5425 {
5426 s->data[i] = s->secretcombo[sSTAIRS];
5427 s->cset[i] = s->secretcset[sSTAIRS];
5428 s->sflag[i] = s->secretflag[sSTAIRS];
5429 sfx(tmpscr->secretsfx);
5430 }
5431
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 486 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
492 else if((flag2 >= 16)&&(flag2 <= 31))
5432 {
5433 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5434 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5435 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5436 }
5437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 else if(flag2 == mfARMOS_SECRET)
5438 {
5439 s->data[i] = s->secretcombo[sSTAIRS];
5440 s->cset[i] = s->secretcset[sSTAIRS];
5441 s->sflag[i] = s->secretflag[sSTAIRS];
5442 sfx(tmpscr->secretsfx);
5443 }
5444 492 else pound = true;
5445 527 }
5446
5447
1/2
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
527 if(!ignoreffc)
5448 {
5449 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5450 {
5451 findentrance(fx,fy,mfHAMMER,true);
5452 findentrance(fx,fy,mfSTRIKE,true);
5453 }
5454 else
5455 {
5456 zc_ffc_modify(s->ffcs[current_ffcombo], 1);
5457 }
5458 }
5459
5460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if(!ignorescreen)
5461 {
5462
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 492 times.
527 if(pound)
5463 492 s->data[i]+=1;
5464
5465 527 set_bit(grid,i,1);
5466
5467
5/8
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 523 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
527 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5468 {
5469
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5470 4 sfx(tmpscr->secretsfx);
5471 4 }
5472
5473
4/4
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 311 times.
527 if(type==cPOUND && get_qr(qr_MORESOUNDS))
5474 311 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5475
5476 527 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5477 527 }
5478
5479
1/2
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
527 if(!ignoreffc)
5480 {
5481 set_bit(ffcgrid,current_ffcombo,1);
5482
5483 if(type2==cPOUND && get_qr(qr_MORESOUNDS))
5484 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5485 }
5486
5487 527 return;
5488 5120 }
5489
5490 void HeroClass::check_pound_block_layer(int bx, int by, int lyr, weapon* w)
5491 {
5492 if(lyr < 1 || lyr > 2) return; //sanity
5493 //keep things inside the screen boundaries
5494 bx=vbound(bx, 0, 255);
5495 by=vbound(by, 0, 176);
5496 int32_t cid = MAPCOMBOL(lyr,bx,by);
5497 newcombo const& scr_cmb = combobuf[cid];
5498 auto* grid = w ? w->wscreengrid_layer[lyr-1] : screengrid_layer[lyr-1];
5499
5500 //first things first
5501 if(z>8||fakez>8) return;
5502
5503 //find out which combo row/column the coordinates are in
5504 bx &= 0xF0;
5505 by &= 0xF0;
5506
5507 int32_t type = scr_cmb.type;
5508 int32_t flag = MAPFLAGL(lyr,bx,by);
5509 int32_t flag2 = scr_cmb.flag;
5510 int32_t i = (bx>>4) + by;
5511
5512 if(i > 175)
5513 return;
5514
5515 bool pound=false;
5516
5517 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5518 return;
5519
5520 if(get_bit(grid, i) != 0)
5521 return;
5522
5523 mapscr *s = FFCore.tempScreens[lyr];
5524
5525 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5526 {
5527 findentrance(bx,by,mfHAMMER,true);
5528 findentrance(bx,by,mfSTRIKE,true);
5529 }
5530 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5531 {
5532 findentrance(bx,by,mfHAMMER,true);
5533 findentrance(bx,by,mfSTRIKE,true);
5534 }
5535 else if((flag >= 16)&&(flag <= 31))
5536 {
5537 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5538 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5539 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5540 }
5541 else if(flag == mfARMOS_SECRET)
5542 {
5543 s->data[i] = s->secretcombo[sSTAIRS];
5544 s->cset[i] = s->secretcset[sSTAIRS];
5545 s->sflag[i] = s->secretflag[sSTAIRS];
5546 sfx(tmpscr->secretsfx);
5547 }
5548 else if((flag2 >= 16)&&(flag2 <= 31))
5549 {
5550 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5551 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5552 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5553 }
5554 else if(flag2 == mfARMOS_SECRET)
5555 {
5556 s->data[i] = s->secretcombo[sSTAIRS];
5557 s->cset[i] = s->secretcset[sSTAIRS];
5558 s->sflag[i] = s->secretflag[sSTAIRS];
5559 sfx(tmpscr->secretsfx);
5560 }
5561 else pound = true;
5562
5563 if(pound)
5564 s->data[i]+=1;
5565
5566 set_bit(grid,i,1);
5567
5568 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5569 {
5570 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5571 sfx(tmpscr->secretsfx);
5572 }
5573
5574 if(type==cPOUND && get_qr(qr_MORESOUNDS))
5575 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5576
5577 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5578 }
5579
5580 void HeroClass::check_wand_block(weapon *w)
5581 {
5582
5583 int32_t par_item = w->parentitem;
5584 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
5585 int32_t usewpn = -1;
5586 if ( par_item > -1 )
5587 {
5588 usewpn = itemsbuf[par_item].useweapon;
5589 }
5590 else if ( par_item == -1 && w->ScriptGenerated )
5591 {
5592 usewpn = w->useweapon;
5593 }
5594 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
5595 if(usewpn != wWand) return;
5596
5597
5598 int32_t bx = 0, by = 0;
5599 bx = ((int32_t)w->x) + (((int32_t)w->hit_width)/2);
5600 by = ((int32_t)w->y) + (((int32_t)w->hit_height)/2);
5601
5602 //keep things inside the screen boundaries
5603 bx=vbound(bx, 0, 255);
5604 by=vbound(by, 0, 176);
5605 int32_t fx=vbound(bx, 0, 255);
5606 int32_t fy=vbound(by, 0, 176);
5607 int32_t cid = MAPCOMBO(bx,by);
5608 //first things first
5609 if(z>8||fakez>8) return;
5610
5611 //find out which combo row/column the coordinates are in
5612 bx &= 0xF0;
5613 by &= 0xF0;
5614
5615 int32_t flag = MAPFLAG(bx,by);
5616 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5617 int32_t flag3=0;
5618 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5619 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5620 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5621 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5622
5623 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5624 flag3=mfWAND;
5625
5626 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5627 flag3=mfSTRIKE;
5628
5629 int32_t i = (bx>>4) + by;
5630
5631 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5632 return;
5633
5634 if(i > 175)
5635 return;
5636
5637 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5638
5639 //findentrance(bx,by,mfWAND,true);
5640 //findentrance(bx,by,mfSTRIKE,true);
5641 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5642 {
5643 if(flag3==mfWAND||flag3==mfSTRIKE)
5644 {
5645 findentrance(fx,fy,mfWAND,true);
5646 findentrance(fx,fy,mfSTRIKE,true);
5647 }
5648 }
5649
5650 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5651 }
5652
5653 //defend results should match defence types.
5654 //RETURN VALUES:
5655 // -1 iGNORE WEAPON
5656 // 0 No effects
5657 // 1 Effects, weapon is not ignored or removed
5658 11528 int32_t HeroClass::defend(weapon *w)
5659 {
5660 11528 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5661
2/25
✓ Branch 0 taken 11519 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
11528 switch(def)
5662 {
5663 11519 case edNORMAL: return 1;
5664 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5665 {
5666 w->power *= 0.5;
5667 return 1;
5668 }
5669 case edQUARTDAMAGE:
5670 {
5671 w->power *= 0.25;
5672 return 1;
5673 }
5674 case edSTUNONLY:
5675 {
5676 setStunClock(120);
5677 return 1;
5678 }
5679 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5680 {
5681 if (w->power > 0)
5682 {
5683 setStunClock(120);
5684 return 1;
5685 }
5686 else
5687 {
5688 sfx(WAV_CHINK,pan(int32_t(x)));
5689 w->dead = 0;
5690 return -1;
5691 }
5692 }
5693 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5694 {
5695 if (w->power > 0)
5696 {
5697 setStunClock(120);
5698 return 1;
5699 }
5700 else
5701 {
5702 return -1;
5703 }
5704 }
5705 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5706 {
5707 if (w->power < 1)
5708 {
5709 sfx(WAV_CHINK,pan(int32_t(x)));
5710 w->dead = 0;
5711 return -1;
5712 }
5713 else
5714 {
5715 return 1;
5716 }
5717 }
5718 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5719 {
5720 if (w->power < 2)
5721 {
5722 sfx(WAV_CHINK,pan(int32_t(x)));
5723 w->dead = 0;
5724 return -1;
5725 }
5726 else
5727 {
5728 return 1;
5729 }
5730 }
5731 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5732 {
5733 if (w->power < 4)
5734 {
5735 sfx(WAV_CHINK,pan(int32_t(x)));
5736 w->dead = 0;
5737 return -1;
5738 }
5739 else
5740 {
5741 return 1;
5742 }
5743 }
5744 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5745 {
5746 if (w->power < 6)
5747 {
5748 sfx(WAV_CHINK,pan(int32_t(x)));
5749 w->dead = 0;
5750 return -1;
5751 }
5752 else
5753 {
5754 return 1;
5755 }
5756 }
5757 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5758 {
5759 if (w->power < 8)
5760 {
5761 sfx(WAV_CHINK,pan(int32_t(x)));
5762 w->dead = 0;
5763 return -1;
5764 }
5765 else
5766 {
5767 return 1;
5768 }
5769 }
5770 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5771 {
5772 sfx(WAV_CHINK,pan(int32_t(x)));
5773 w->dead = 0;
5774 return -1;
5775 }
5776 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5777 {
5778 if (w->power < 1)
5779 {
5780 return -1;
5781 }
5782 else return 1;
5783 }
5784 case edIGNORE: // : IMPLEMENTED : Do Nothing
5785 {
5786 return -1;
5787 }
5788 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5789 {
5790 game->set_life(0);
5791 return 1;
5792 }
5793 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5794 {
5795 if (w->power < 10)
5796 {
5797 sfx(WAV_CHINK,pan(int32_t(x)));
5798 w->dead = 0;
5799 return -1;
5800 }
5801 else
5802 {
5803 return 1;
5804 }
5805 }
5806 case ed2x: // : IMPLEMENTED : Double damage.
5807 {
5808 w->power *= 2;
5809 return 1;
5810 }
5811 case ed3x: // : IMPLEMENTED : Triple Damage.
5812 {
5813 w->power *= 3;
5814 return 1;
5815 }
5816 case ed4x: // : IMPLEMENTED : 4x damage.
5817 {
5818 w->power *= 4;
5819 return 1;
5820 }
5821 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5822 {
5823 //sfx(WAV_HEAL,pan(int32_t(x)));
5824 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5825 w->dead = 0;
5826 return -1;
5827 }
5828
5829 case edFREEZE: return 1; //Not IMPLEMENTED
5830
5831 case edLEVELDAMAGE: //Damage * item level
5832 {
5833 w->power *= w->family_level;
5834 return 1;
5835 }
5836 case edLEVELREDUCTION: //Damage / item level
5837 {
5838 if ( w->family_level > 0 )
5839 {
5840 w->power /= w->family_level;
5841 }
5842 else w->power = 0;
5843 return 1;
5844 }
5845
5846 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5847 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5848 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5849 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5850
5851 //edSHOCK, //buzz blob
5852
5853
5854 case edBREAKSHIELD: //destroy the player's present shield
5855 {
5856 w->power = 0;
5857 w->dead = 0;
5858 int32_t itemid = getCurrentShield();
5859 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5860 if(itemsbuf[itemid].flags&ITEM_EDIBLE)
5861 game->set_item(itemid, false);
5862 //Remove Hero's shield
5863 return -1;
5864 }
5865
5866
5867
5868 9 default: return 0;
5869 }
5870 11528 }
5871 ALLEGRO_COLOR HeroClass::hitboxColor(byte opacity) const
5872 {
5873 return al_map_rgba(0,0,255,opacity);
5874 }
5875 10935 int32_t HeroClass::compareDir(int32_t other)
5876 {
5877
5/6
✓ Branch 0 taken 10918 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10918 times.
✓ Branch 4 taken 105 times.
✓ Branch 5 taken 10830 times.
10935 if(other != NORMAL_DIR(other))
5878 105 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5879 10830 int32_t ret = 0;
5880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10830 times.
10830 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5881
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2141 times.
✓ Branch 2 taken 1854 times.
✓ Branch 3 taken 3459 times.
✓ Branch 4 taken 3376 times.
10830 switch(d)
5882 {
5883 case up:
5884 {
5885
3/3
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 848 times.
✓ Branch 2 taken 784 times.
2141 switch(X_DIR(other))
5886 {
5887 case left:
5888 848 ret |= CMPDIR_RIGHT;
5889 848 break;
5890 case right:
5891 784 ret |= CMPDIR_LEFT;
5892 784 break;
5893 }
5894
3/3
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 1551 times.
2141 switch(Y_DIR(other))
5895 {
5896 case up:
5897 335 ret |= CMPDIR_BACK;
5898 335 break;
5899 case down:
5900 1551 ret |= CMPDIR_FRONT;
5901 1551 break;
5902 }
5903 2141 break;
5904 }
5905 case down:
5906 {
5907
3/3
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 617 times.
✓ Branch 2 taken 709 times.
1854 switch(X_DIR(other))
5908 {
5909 case left:
5910 617 ret |= CMPDIR_LEFT;
5911 617 break;
5912 case right:
5913 709 ret |= CMPDIR_RIGHT;
5914 709 break;
5915 }
5916
3/3
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1262 times.
✓ Branch 2 taken 317 times.
1854 switch(Y_DIR(other))
5917 {
5918 case up:
5919 1262 ret |= CMPDIR_FRONT;
5920 1262 break;
5921 case down:
5922 317 ret |= CMPDIR_BACK;
5923 317 break;
5924 }
5925 1854 break;
5926 }
5927 case left:
5928 {
5929
3/3
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 494 times.
✓ Branch 2 taken 2768 times.
3459 switch(X_DIR(other))
5930 {
5931 case left:
5932 494 ret |= CMPDIR_BACK;
5933 494 break;
5934 case right:
5935 2768 ret |= CMPDIR_FRONT;
5936 2768 break;
5937 }
5938
3/3
✓ Branch 0 taken 1383 times.
✓ Branch 1 taken 891 times.
✓ Branch 2 taken 1185 times.
3459 switch(Y_DIR(other))
5939 {
5940 case up:
5941 891 ret |= CMPDIR_LEFT;
5942 891 break;
5943 case down:
5944 1185 ret |= CMPDIR_RIGHT;
5945 1185 break;
5946 }
5947 3459 break;
5948 }
5949 case right:
5950 {
5951
3/3
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 2705 times.
✓ Branch 2 taken 482 times.
3376 switch(X_DIR(other))
5952 {
5953 case left:
5954 2705 ret |= CMPDIR_FRONT;
5955 2705 break;
5956 case right:
5957 482 ret |= CMPDIR_BACK;
5958 482 break;
5959 }
5960
3/3
✓ Branch 0 taken 1336 times.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1208 times.
3376 switch(Y_DIR(other))
5961 {
5962 case up:
5963 832 ret |= CMPDIR_RIGHT;
5964 832 break;
5965 case down:
5966 1208 ret |= CMPDIR_LEFT;
5967 1208 break;
5968 }
5969 3376 break;
5970 }
5971 }
5972 10830 return ret;
5973 10935 }
5974
5975 10935 bool compareShield(int32_t cmpdir, itemdata const& shield)
5976 {
5977
1/2
✓ Branch 0 taken 10935 times.
✗ Branch 1 not taken.
10935 bool standard = !(shield.flags&ITEM_FLAG9) || usingActiveShield();
5978
1/2
✓ Branch 0 taken 10935 times.
✗ Branch 1 not taken.
10935 if(standard) //Use standard sides, either a passive shield, or a held active shield
5979 {
5980
4/4
✓ Branch 0 taken 8286 times.
✓ Branch 1 taken 2649 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 8277 times.
10935 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG1))
5981 8277 return true;
5982
3/4
✓ Branch 0 taken 1628 times.
✓ Branch 1 taken 1030 times.
✓ Branch 2 taken 1628 times.
✗ Branch 3 not taken.
2658 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG2))
5983 return true;
5984
3/4
✓ Branch 0 taken 1029 times.
✓ Branch 1 taken 1629 times.
✓ Branch 2 taken 1029 times.
✗ Branch 3 not taken.
2658 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG3))
5985 return true;
5986
3/4
✓ Branch 0 taken 1140 times.
✓ Branch 1 taken 1518 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1140 times.
2658 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG4))
5987 return true;
5988 2658 }
5989 else //Active Shield that is NOT held down
5990 {
5991 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG5))
5992 return true;
5993 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG6))
5994 return true;
5995 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG7))
5996 return true;
5997 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG8))
5998 return true;
5999 }
6000 2658 return false;
6001 10935 }
6002
6003 7259 static bool sh_check(uint fl_block, uint fl_ref, int wty, bool& reflect, bool boss, bool defret)
6004 {
6005 7259 reflect = false;
6006
10/20
✓ Branch 0 taken 3555 times.
✓ Branch 1 taken 329 times.
✓ Branch 2 taken 416 times.
✓ Branch 3 taken 988 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 510 times.
✓ Branch 6 taken 1039 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 20 times.
✓ Branch 9 taken 391 times.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
7259 switch(wty)
6007 {
6008 case ewBrang:
6009
1/2
✓ Branch 0 taken 391 times.
✗ Branch 1 not taken.
391 if(!(fl_block & shBRANG)) break;
6010
6011 391 reflect = ((fl_ref & shBRANG) != 0);
6012 391 return true;
6013 case ewArrow:
6014 case wRefArrow:
6015
1/2
✓ Branch 0 taken 329 times.
✗ Branch 1 not taken.
329 if(!(fl_block & shARROW)) break;
6016
6017 329 reflect = ((fl_ref & shARROW) != 0);
6018 329 return true;
6019
6020 case ewRock:
6021 case wRefRock:
6022
1/2
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
416 if(!(fl_block & shROCK)) break;
6023
6024 416 reflect = ((fl_ref & shROCK) != 0);
6025 416 return true;
6026 case ewFlame:
6027 case wRefFire:
6028
2/2
✓ Branch 0 taken 639 times.
✓ Branch 1 taken 349 times.
988 if(!(fl_block & shFLAME)) break;
6029
6030 639 reflect = ((fl_ref & shFLAME) != 0);
6031 639 return true;
6032 case ewFlame2:
6033 case wRefFire2:
6034 if(get_qr(qr_BROKEN_FLAME_ARROW_REFLECTING))
6035 return true;
6036 if(!(fl_block & shFLAME2)) break;
6037
6038 reflect = ((fl_ref & shFLAME2) != 0);
6039 return true;
6040
6041 case ewFireball2:
6042 case ewFireball:
6043 case wRefFireball:
6044 {
6045 3555 int32_t mask = (boss ? shFIREBALL2 : shFIREBALL);
6046
6047
2/2
✓ Branch 0 taken 3071 times.
✓ Branch 1 taken 484 times.
3555 if(!(fl_block & mask)) break;
6048
6049 3071 reflect = ((fl_ref & mask) != 0);
6050 3071 return true;
6051 }
6052
6053 case ewSword:
6054 case wRefBeam:
6055
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 91 times.
510 if(!(fl_block & shSWORD)) break;
6056
6057 419 reflect = ((fl_ref & shSWORD) != 0);
6058 419 return true;
6059
6060 case wRefMagic:
6061 case ewMagic:
6062
2/2
✓ Branch 0 taken 969 times.
✓ Branch 1 taken 70 times.
1039 if(!(fl_block & shMAGIC)) break;
6063
6064 969 reflect = ((fl_ref & shMAGIC) != 0);
6065 969 return true;
6066
6067 #define SCRIPT_SHBLOCK(scrfl) \
6068 if(!(fl_block & (shSCRIPT|scrfl))) break; \
6069 reflect = ((fl_ref & (shSCRIPT|scrfl)) != 0); \
6070 return true
6071
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 case wScript1: SCRIPT_SHBLOCK(shSCRIPT1);
6072 case wScript2: SCRIPT_SHBLOCK(shSCRIPT2);
6073 case wScript3: SCRIPT_SHBLOCK(shSCRIPT3);
6074 case wScript4: SCRIPT_SHBLOCK(shSCRIPT4);
6075 case wScript5: SCRIPT_SHBLOCK(shSCRIPT5);
6076 case wScript6: SCRIPT_SHBLOCK(shSCRIPT6);
6077 case wScript7: SCRIPT_SHBLOCK(shSCRIPT7);
6078 case wScript8: SCRIPT_SHBLOCK(shSCRIPT8);
6079 case wScript9: SCRIPT_SHBLOCK(shSCRIPT9);
6080 case wScript10: SCRIPT_SHBLOCK(shSCRIPT10);
6081 #undef SCRIPT_SHBLOCK
6082
6083 case ewLitBomb:
6084 case ewLitSBomb:
6085 2 return true;
6086
6087 default:
6088 20 return defret;
6089 }
6090 1003 return false;
6091 7259 }
6092
6093 bool HeroClass::check_ewpn_collide(weapon* w)
6094 {
6095 if(w->ignoreHero || w->fallclk|| w->drownclk)
6096 return false;
6097 if(!w->hit(x+7,y+7-fakez,z,2,2,1))
6098 return false;
6099
6100 int32_t stompid = current_item_id(itype_stompboots);
6101
6102 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6103 ((z+fakez) > (w->z+(w->fakez))) ||
6104 ((isSideViewHero() && (y+16)-(w->y)<=14) && falling_oldy<y)))
6105 {
6106 itemdata const& stomp = itemsbuf[stompid];
6107 bool reflect = false; //unused, always false
6108 if(!sh_check(stomp.misc2, 0, w->id, reflect, w->type&1, true))
6109 {
6110 w->onhit(false);
6111 sfx(WAV_CHINK,pan(x.getInt()));
6112 return false;
6113 }
6114 }
6115
6116 int32_t defresult = defend(w);
6117 if ( defresult == -1 ) return false; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6118
6119 if(w->id==ewWind)
6120 {
6121 xofs=1000;
6122 action=freeze; FFCore.setHeroAction(freeze);
6123 w->misc=999; // in enemy wind
6124 attackclk=0;
6125 return false;
6126 }
6127
6128 switch(w->id)
6129 {
6130 case ewLitBomb:
6131 case ewBomb:
6132 case ewLitSBomb:
6133 case ewSBomb:
6134 return true;
6135 }
6136
6137 int32_t itemid = getCurrentShield(false);
6138 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6139 return true;
6140 itemdata const& shield = itemsbuf[itemid];
6141 bool allow_inactive = (shield.flags & ITEM_FLAG9);
6142 auto cmpdir = compareDir(w->dir);
6143 bool hitshield = compareShield(cmpdir, shield);
6144
6145 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6146 return true;
6147
6148 if(!hitshield)
6149 return true;
6150
6151 paymagiccost(itemid);
6152
6153 bool reflect = false;
6154
6155 if(!sh_check(shield.misc1, shield.misc2, w->id, reflect, w->type&1, true))
6156 return true;
6157
6158 if(reflect && (w->unblockable&WPNUNB_REFL))
6159 reflect = false;
6160 if(!reflect && (w->unblockable&WPNUNB_SHLD))
6161 return true;
6162
6163 int32_t oldid = w->id;
6164 w->onhit(false, reflect ? 2 : 1, dir);
6165
6166 sfx(shield.usesound,pan(x.getInt()));
6167 return true;
6168 }
6169
6170 12812922 int32_t HeroClass::EwpnHit()
6171 {
6172
2/2
✓ Branch 0 taken 12807505 times.
✓ Branch 1 taken 7480482 times.
20287987 for(int32_t i=0; i<Ewpns.Count(); i++)
6173 {
6174
2/2
✓ Branch 0 taken 7468954 times.
✓ Branch 1 taken 11528 times.
7480482 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6175 {
6176 11528 weapon *ew = (weapon*)(Ewpns.spr(i));
6177
6178
3/6
✓ Branch 0 taken 11528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11528 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11528 times.
11528 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
6179 break;
6180
6181 11528 int32_t stompid = current_item_id(itype_stompboots);
6182
6183
5/10
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11522 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11528 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6184
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((z+fakez) > (ew->z+(ew->fakez))) ||
6185
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
6186 {
6187 itemdata const& stomp = itemsbuf[stompid];
6188 bool reflect = false; //unused, always false
6189 if(!sh_check(stomp.misc2, 0, ew->id, reflect, ew->type&1, true))
6190 {
6191 ew->onhit(false);
6192 sfx(WAV_CHINK,pan(x.getInt()));
6193 continue;
6194 }
6195 }
6196
6197 11528 int32_t defresult = defend(ew);
6198
1/2
✓ Branch 0 taken 11528 times.
✗ Branch 1 not taken.
11528 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6199
6200
2/2
✓ Branch 0 taken 11525 times.
✓ Branch 1 taken 3 times.
11528 if(ew->id==ewWind)
6201 {
6202 3 xofs=1000;
6203 3 action=freeze; FFCore.setHeroAction(freeze);
6204 3 ew->misc=999; // in enemy wind
6205 3 attackclk=0;
6206 3 return -1;
6207 }
6208
6209
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 11434 times.
11525 switch(ew->id)
6210 {
6211 case ewLitBomb:
6212 case ewBomb:
6213 case ewLitSBomb:
6214 case ewSBomb:
6215 91 return i;
6216 }
6217
6218 11434 int32_t itemid = getCurrentShield(false);
6219
4/6
✓ Branch 0 taken 10923 times.
✓ Branch 1 taken 511 times.
✓ Branch 2 taken 10923 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10923 times.
11434 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6220 511 return i;
6221 10923 itemdata const& shield = itemsbuf[itemid];
6222 10923 bool allow_inactive = (shield.flags & ITEM_FLAG9);
6223 10923 auto cmpdir = compareDir(ew->dir);
6224 10923 bool hitshield = compareShield(cmpdir, shield);
6225
6226
12/20
✓ Branch 0 taken 10923 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10923 times.
✓ Branch 4 taken 8813 times.
✓ Branch 5 taken 2110 times.
✓ Branch 6 taken 8813 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8751 times.
✓ Branch 9 taken 62 times.
✓ Branch 10 taken 8751 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 8751 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 8751 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 8751 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 8751 times.
✗ Branch 19 not taken.
10923 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6227 2172 return i;
6228
6229
2/2
✓ Branch 0 taken 6765 times.
✓ Branch 1 taken 1986 times.
8751 if(!hitshield)
6230 1986 return i;
6231
6232 6765 paymagiccost(itemid);
6233
6234 6765 bool reflect = false;
6235
6236
2/2
✓ Branch 0 taken 6111 times.
✓ Branch 1 taken 654 times.
6765 if(!sh_check(shield.misc1, shield.misc2, ew->id, reflect, ew->type&1, true))
6237 654 return i;
6238
6239
3/4
✓ Branch 0 taken 1609 times.
✓ Branch 1 taken 4502 times.
✓ Branch 2 taken 1609 times.
✗ Branch 3 not taken.
6111 if(reflect && (ew->unblockable&WPNUNB_REFL))
6240 reflect = false;
6241
3/4
✓ Branch 0 taken 4502 times.
✓ Branch 1 taken 1609 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4502 times.
6111 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6242 return i;
6243
6244 6111 int32_t oldid = ew->id;
6245 6111 ew->onhit(false, reflect ? 2 : 1, dir);
6246
6247 6111 sfx(shield.usesound,pan(x.getInt()));
6248 6111 }
6249 7475065 }
6250
6251 12807505 return -1;
6252 12812922 }
6253
6254 12812932 int32_t HeroClass::LwpnHit() //only here to check magic hits
6255 {
6256
2/2
✓ Branch 0 taken 12642824 times.
✓ Branch 1 taken 4267475 times.
16910299 for(int32_t i=0; i<Lwpns.Count(); i++)
6257
2/2
✓ Branch 0 taken 4097361 times.
✓ Branch 1 taken 170114 times.
4267481 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6258 {
6259 170114 weapon *lw = (weapon*)(Lwpns.spr(i));
6260
6261
2/2
✓ Branch 0 taken 165520 times.
✓ Branch 1 taken 4594 times.
170114 if((lw->ignoreHero)==true)
6262 4594 break;
6263
6264
2/2
✓ Branch 0 taken 165504 times.
✓ Branch 1 taken 16 times.
165520 switch(lw->id)
6265 {
6266 case wRefFireball:
6267 case wRefMagic:
6268 case wRefBeam:
6269 case wRefRock:
6270 case wRefArrow:
6271 case wRefFire:
6272 case wRefFire2:
6273 16 break;
6274 default:
6275 165504 return -1;
6276 }
6277 16 int32_t itemid = getCurrentShield(false);
6278
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
16 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6279 4 return i;
6280 12 itemdata const& shield = itemsbuf[itemid];
6281 12 auto cmpdir = compareDir(lw->dir);
6282 12 bool hitshield = compareShield(cmpdir, shield);
6283 12 bool reflect = false;
6284
6285
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(!hitshield)
6286 6 return i;
6287
6288 6 bool allow_inactive = (shield.flags & ITEM_FLAG9);
6289
10/20
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 6 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 6 times.
✗ Branch 19 not taken.
6 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6290 return i;
6291
6292
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!sh_check(shield.misc1, shield.misc2, lw->id, reflect, lw->type&1, true))
6293 return i;
6294
6295 6 paymagiccost(itemid);
6296
6297 6 lw->onhit(false, reflect ? 2 : 1, dir);
6298 6 sfx(shield.usesound,pan(x.getInt()));
6299 6 }
6300
6301 12647418 return -1;
6302 12812932 }
6303
6304 120 bool HeroClass::try_lwpn_hit(weapon* w)
6305 {
6306 120 int32_t itemid = w->parentitem;
6307 120 int indx = Lwpns.find(w);
6308 //if ( itemdbuf[parentitem].flags&ITEM_FLAGS3 ) //can damage Hero
6309 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6310
8/14
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 80 times.
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 40 times.
✓ Branch 6 taken 40 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 40 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 40 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
120 if((!(itemid==-1&&get_qr(qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & ITEM_FLAG3)))) && scriptcoldet && !fallclk && (!superman || !get_qr(qr_FIREPROOFHERO2)))
6311 {
6312
2/10
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 40 times.
40 if(w->id==wFire && (superman ? (diagonalMovement?w->hit(x+4,y+4-fakez,z,7,7,1):w->hit(x+7,y+7-fakez,z,2,2,1)) : w->hit(this))&&
6313 (itemid < 0 || itemsbuf[itemid].family!=itype_divinefire))
6314 {
6315 std::vector<int32_t> &ev = FFCore.eventData;
6316 ev.clear();
6317 ev.push_back(lwpn_dp(indx)*10000);
6318 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6319 ev.push_back(0);
6320 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6321 ev.push_back(48*10000);
6322 ev.push_back(ZSD_LWPN*10000);
6323 ev.push_back(w->getUID());
6324 ev.push_back(ZSD_NONE*10000);
6325 ev.push_back(0);
6326
6327 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6328 int32_t dmg = ev[0]/10000;
6329 bool nullhit = ev[2] != 0;
6330
6331 if(nullhit) {ev.clear(); return true;}
6332
6333 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6334 ev[0] = ringpower(dmg)*10000;
6335
6336 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6337 dmg = ev[0]/10000;
6338 int32_t hdir = ev[1]/10000;
6339 nullhit = ev[2] != 0;
6340 bool divineprot = ev[3] != 0;
6341 int32_t iframes = ev[4] / 10000;
6342 ev.clear();
6343 if(nullhit) return true;
6344 if (Lwpns.spr(indx) != w)
6345 {
6346 auto hit = Lwpns.find(w);
6347 if (hit < 0)
6348 w = nullptr;
6349 else
6350 {
6351 w = (weapon*)Lwpns.spr(hit);
6352 indx = hit;
6353 }
6354 }
6355 if(!divineprot)
6356 {
6357 game->set_life(zc_max(game->get_life()-dmg,0));
6358 if (!get_qr(qr_BROKENHITBY) && w)
6359 {
6360 sethitHeroUID(HIT_BY_LWEAPON,(indx+1));
6361 if (get_qr(qr_BROKENHITBY))
6362 {
6363 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6364 }
6365 else
6366 {
6367
6368 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getScriptUID());
6369 }
6370 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6371 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6372 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6373 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6374 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].family);
6375 }
6376 }
6377
6378 hitdir = hdir;
6379
6380 if (action != rafting && action != freeze && action != sideswimfreeze)
6381 {
6382 if (IsSideSwim())
6383 {
6384 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6385 }
6386 else if (action == swimming || hopclk == 0xFF)
6387 {
6388 action=swimhit; FFCore.setHeroAction(swimhit);
6389 }
6390 else
6391 {
6392 action=gothit; FFCore.setHeroAction(gothit);
6393 }
6394 }
6395
6396 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6397 {
6398 spins = charging = attackclk = 0;
6399 attack=none;
6400 tapping = false;
6401 }
6402
6403 hclk=iframes;
6404 sfx(getHurtSFX(),pan(x.getInt()));
6405 return true;
6406 }
6407 40 }
6408
6409 // check enemy weapons true, 1, -1
6410 //
6411
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if((itemsbuf[itemid].flags & ITEM_FLAG6))
6412 {
6413 if(w->id==wBrang || (w->id==wHookshot&&!pull_hero))
6414 {
6415 int32_t itemid = w->parentitem>-1 ? w->parentitem :
6416 directWpn>-1 ? directWpn : current_item_id(w->id==wHookshot ? (w->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6417 itemid = vbound(itemid, 0, MAXITEMS-1);
6418
6419 for(int32_t j=0; j<Ewpns.Count(); j++)
6420 {
6421 sprite *t = Ewpns.spr(j);
6422
6423 if(w->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6424 {
6425 bool reflect = false;
6426 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6427 if(sh_check(itemsbuf[itemid].misc3, itemsbuf[itemid].misc4, t->id, reflect, ((weapon*)t)->type&1, false))
6428 {
6429 w->dead=1;
6430 weapon *ew = ((weapon*)t);
6431 int32_t oldid = ew->id;
6432 ew->onhit(true, reflect ? 2 : 1, w->dir);
6433 }
6434
6435 break;
6436 }
6437 }
6438 }
6439 }
6440
6441
2/6
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
40 if((itemsbuf[itemid].flags & ITEM_FLAG2)||(itemid==-1&&get_qr(qr_OUCHBOMBS)))
6442 {
6443 if(((w->id==wBomb)||(w->id==wSBomb)) && !superman && scriptcoldet && !fallclk)
6444 {
6445 bool didhit = w->hit(this);
6446 if(didhit)
6447 {
6448 std::vector<int32_t> &ev = FFCore.eventData;
6449 ev.clear();
6450 ev.push_back(((w->parentitem>-1 ? itemsbuf[w->parentitem].misc3 : w->power) *game->get_hp_per_heart())*10000);
6451 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6452 ev.push_back(0);
6453 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6454 ev.push_back(48*10000);
6455 ev.push_back(ZSD_LWPN*10000);
6456 ev.push_back(w->getUID());
6457 ev.push_back(ZSD_NONE*10000);
6458 ev.push_back(0);
6459
6460 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6461 int32_t dmg = ev[0]/10000;
6462 bool nullhit = ev[2] != 0;
6463
6464 if(nullhit) {ev.clear(); return true;}
6465
6466 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6467 ev[0] = ringpower(dmg)*10000;
6468
6469 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6470 dmg = ev[0]/10000;
6471 int32_t hdir = ev[1]/10000;
6472 nullhit = ev[2] != 0;
6473 bool divineprot = ev[3] != 0;
6474 int32_t iframes = ev[4] / 10000;
6475 ev.clear();
6476 if(nullhit) return true;
6477 if (Lwpns.spr(indx) != w)
6478 {
6479 auto hit = Lwpns.find(w);
6480 if (hit < 0)
6481 w = nullptr;
6482 else
6483 {
6484 w = (weapon*)Lwpns.spr(hit);
6485 indx = hit;
6486 }
6487 }
6488 if(!divineprot)
6489 {
6490 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6491 if (!get_qr(qr_BROKENHITBY) && w)
6492 {
6493 sethitHeroUID(HIT_BY_LWEAPON,(indx+1));
6494 if (get_qr(qr_BROKENHITBY))
6495 {
6496 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6497 }
6498 else
6499 {
6500
6501 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getScriptUID());
6502 }
6503 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6504 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6505 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6506 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6507 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].family);
6508 }
6509 }
6510
6511 hitdir = hdir;
6512
6513 if (action != rafting && action != freeze && action != sideswimfreeze)
6514 {
6515 if (IsSideSwim())
6516 {
6517 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6518 }
6519 else if (action == swimming || hopclk == 0xFF)
6520 {
6521 action=swimhit; FFCore.setHeroAction(swimhit);
6522 }
6523 else
6524 {
6525 action=gothit; FFCore.setHeroAction(gothit);
6526 }
6527 }
6528
6529 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6530 {
6531 spins = charging = attackclk = 0;
6532 attack=none;
6533 tapping = false;
6534 }
6535
6536 hclk=iframes;
6537 sfx(getHurtSFX(),pan(x.getInt()));
6538 return true;
6539 }
6540 }
6541 }
6542
6543
4/8
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 40 times.
40 if(hclk==0 && w->id==wWind && w->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6544 {
6545 std::vector<int32_t> &ev = FFCore.eventData;
6546 ev.clear();
6547 ev.push_back(0);
6548 ev.push_back(w->dir*10000);
6549 ev.push_back(0);
6550 ev.push_back(0);
6551 ev.push_back(ZSD_LWPN*10000);
6552 ev.push_back(w->getUID());
6553 ev.push_back(ZSD_NONE*10000);
6554 ev.push_back(0);
6555
6556 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6557 bool nullhit = ev[2] != 0;
6558 if(nullhit) {ev.clear(); return true;}
6559
6560 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6561 int32_t hdir = ev[1]/10000;
6562 nullhit = ev[2] != 0;
6563 ev.clear();
6564 if(nullhit) return true;
6565 if (Lwpns.spr(indx) != w)
6566 {
6567 auto hit = Lwpns.find(w);
6568 if (hit < 0)
6569 w = nullptr;
6570 else
6571 {
6572 w = (weapon*)Lwpns.spr(hit);
6573 indx = hit;
6574 }
6575 }
6576
6577 reset_hookshot();
6578 xofs=1000;
6579 action=inwind; FFCore.setHeroAction(inwind);
6580 dir = hdir;
6581 if(w) w->dir = hdir;
6582 spins = charging = attackclk = 0;
6583
6584 // In case Hero used two whistles in a row, summoning two whirlwinds,
6585 // check which whistle's whirlwind picked him up so the correct
6586 // warp ring will be used
6587 int32_t whistle = w ? w->parentitem : -1;
6588
6589 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6590 whistleitem=whistle;
6591
6592 return true;
6593 }
6594 40 return false;
6595 40 }
6596
6597 bool HeroClass::try_ewpn_hit(weapon* w, bool force)
6598 {
6599 if(!force)
6600 {
6601 if(!check_ewpn_collide(w))
6602 return false;
6603 if(w->ignoreHero || w->fallclk|| w->drownclk)
6604 return false;
6605 }
6606 auto indx = Ewpns.find(w);
6607 std::vector<int32_t> &ev = FFCore.eventData;
6608 ev.clear();
6609 ev.push_back((ewpn_dp(indx)*10000));
6610 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6611 ev.push_back(0);
6612 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6613 ev.push_back(48*10000);
6614 ev.push_back(ZSD_EWPN*10000);
6615 ev.push_back(w->getUID());
6616 ev.push_back(ZSD_NONE*10000);
6617 ev.push_back(0);
6618
6619 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6620 int32_t dmg = ev[0]/10000;
6621 bool nullhit = ev[2] != 0;
6622
6623 if(nullhit) {ev.clear(); return false;}
6624
6625 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6626 ev[0] = ringpower(dmg)*10000;
6627
6628 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6629 dmg = ev[0]/10000;
6630 int32_t hdir = ev[1]/10000;
6631 nullhit = ev[2] != 0;
6632 bool divineprot = ev[3] != 0;
6633 int32_t iframes = ev[4] / 10000;
6634 ev.clear();
6635 if (nullhit) return false;
6636 if (Ewpns.spr(indx) != w)
6637 {
6638 indx = Ewpns.find(w);
6639 if (indx < 0)
6640 w = nullptr;
6641 else w = (weapon*)Ewpns.spr(indx);
6642 }
6643 if (!divineprot)
6644 {
6645 game->set_life(zc_max(game->get_life() - dmg, 0));
6646 if (w)
6647 {
6648 sethitHeroUID(HIT_BY_EWEAPON, (indx + 1));
6649 if (get_qr(qr_BROKENHITBY))
6650 {
6651 sethitHeroUID(HIT_BY_EWEAPON_UID, w->getUID());
6652 }
6653 else
6654 {
6655
6656 sethitHeroUID(HIT_BY_EWEAPON_UID, w->getScriptUID());
6657 }
6658 sethitHeroUID(HIT_BY_EWEAPON_ENGINE_UID, w->getUID());
6659 sethitHeroUID(HIT_BY_EWEAPON_TYPE, w->id);
6660 }
6661 }
6662
6663 hitdir = hdir;
6664 if(w)
6665 w->onhit(false);
6666
6667 if (IsSideSwim())
6668 {
6669 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6670 }
6671 else if(action==swimming || hopclk==0xFF)
6672 {
6673 action=swimhit; FFCore.setHeroAction(swimhit);
6674 }
6675 else
6676 {
6677 action=gothit; FFCore.setHeroAction(gothit);
6678 }
6679
6680 hclk=iframes;
6681
6682 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6683 {
6684 spins = charging = attackclk = 0;
6685 attack=none;
6686 tapping = false;
6687 }
6688
6689 sfx(getHurtSFX(),pan(x.getInt()));
6690 return true;
6691 }
6692
6693 20619639 void HeroClass::checkhit()
6694 {
6695
2/2
✓ Branch 0 taken 6455374 times.
✓ Branch 1 taken 14164265 times.
20619639 if(checkhero==true)
6696 {
6697
2/2
✓ Branch 0 taken 13458340 times.
✓ Branch 1 taken 705925 times.
14164265 if(hclk>0)
6698 {
6699 705925 --hclk;
6700 705925 }
6701
6702
1/2
✓ Branch 0 taken 14164265 times.
✗ Branch 1 not taken.
14164265 if(DivineProtectionShieldClk>0)
6703 {
6704 --DivineProtectionShieldClk;
6705
6706 if(DivineProtectionShieldClk == 0 && div_prot_item != -1)
6707 {
6708 stop_sfx(itemsbuf[div_prot_item].usesound);
6709 stop_sfx(itemsbuf[div_prot_item].usesound+1);
6710 div_prot_item = -1;
6711 }
6712 else if(get_qr(qr_MORESOUNDS) && !(DivineProtectionShieldClk&0xF00) && div_prot_item != -1)
6713 {
6714 stop_sfx(itemsbuf[div_prot_item].usesound);
6715 cont_sfx(itemsbuf[div_prot_item].usesound+1);
6716 }
6717 }
6718 14164265 }
6719
6720
4/4
✓ Branch 0 taken 14029290 times.
✓ Branch 1 taken 6590349 times.
✓ Branch 2 taken 14021501 times.
✓ Branch 3 taken 7789 times.
20619639 if(hclk<39 && action==gothit)
6721 {
6722 7789 action=none; FFCore.setHeroAction(none);
6723 7789 }
6724
6725
5/6
✓ Branch 0 taken 14029290 times.
✓ Branch 1 taken 6590349 times.
✓ Branch 2 taken 14029165 times.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14029165 times.
20619639 if(hclk<39 && (action==swimhit || action == sideswimhit))
6726 {
6727 125 SetSwim();
6728 125 }
6729
6730
4/4
✓ Branch 0 taken 120065 times.
✓ Branch 1 taken 20499574 times.
✓ Branch 2 taken 34114 times.
✓ Branch 3 taken 85951 times.
20619639 if(hclk>=40 && action==gothit)
6731 {
6732 85951 int val = check_pitslide();
6733
4/4
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 85523 times.
✓ Branch 2 taken 86127 times.
✓ Branch 3 taken 85699 times.
85951 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6734 {
6735
2/2
✓ Branch 0 taken 344508 times.
✓ Branch 1 taken 86127 times.
430635 for(int32_t i=0; i<4; i++)
6736 {
6737
5/5
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 73364 times.
✓ Branch 2 taken 82808 times.
✓ Branch 3 taken 90156 times.
✓ Branch 4 taken 93764 times.
344508 switch(hitdir)
6738 {
6739 case up:
6740
6/6
✓ Branch 0 taken 5351 times.
✓ Branch 1 taken 68013 times.
✓ Branch 2 taken 11360 times.
✓ Branch 3 taken 56653 times.
✓ Branch 4 taken 5493 times.
✓ Branch 5 taken 67871 times.
73364 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6741 {
6742 5493 action=none; FFCore.setHeroAction(none);
6743 5493 }
6744
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 67847 times.
67871 else if (val == -1) --y;
6745
6746 73364 break;
6747
6748 case down:
6749
6/6
✓ Branch 0 taken 6869 times.
✓ Branch 1 taken 75939 times.
✓ Branch 2 taken 12812 times.
✓ Branch 3 taken 63127 times.
✓ Branch 4 taken 7027 times.
✓ Branch 5 taken 75781 times.
82808 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6750 {
6751 7027 action=none; FFCore.setHeroAction(none);
6752 7027 }
6753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75781 times.
75781 else if (val == -1) ++y;
6754
6755 82808 break;
6756
6757 case left:
6758
7/8
✓ Branch 0 taken 86796 times.
✓ Branch 1 taken 3360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86796 times.
✓ Branch 4 taken 10732 times.
✓ Branch 5 taken 76064 times.
✓ Branch 6 taken 3527 times.
✓ Branch 7 taken 86629 times.
90156 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6759 {
6760 3527 action=none; FFCore.setHeroAction(none);
6761 3527 }
6762
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 86593 times.
86629 else if (val == -1) --x;
6763
6764 90156 break;
6765
6766 case right:
6767
8/8
✓ Branch 0 taken 89718 times.
✓ Branch 1 taken 4046 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 89714 times.
✓ Branch 4 taken 9690 times.
✓ Branch 5 taken 80024 times.
✓ Branch 6 taken 4155 times.
✓ Branch 7 taken 89609 times.
93764 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6768 {
6769 4155 action=none; FFCore.setHeroAction(none);
6770 4155 }
6771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89609 times.
89609 else if (val == -1) ++x;
6772
6773 93764 break;
6774 }
6775 344508 }
6776 86127 }
6777 86303 }
6778
6779
19/20
✓ Branch 0 taken 13472670 times.
✓ Branch 1 taken 7147321 times.
✓ Branch 2 taken 13471721 times.
✓ Branch 3 taken 949 times.
✓ Branch 4 taken 13455239 times.
✓ Branch 5 taken 16482 times.
✓ Branch 6 taken 13450719 times.
✓ Branch 7 taken 4520 times.
✓ Branch 8 taken 13450520 times.
✓ Branch 9 taken 199 times.
✓ Branch 10 taken 13450520 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 13449614 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 13439483 times.
✓ Branch 15 taken 10131 times.
✓ Branch 16 taken 11373 times.
✓ Branch 17 taken 13428110 times.
✓ Branch 18 taken 7850133 times.
✓ Branch 19 taken 7861506 times.
20619991 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6780 {
6781 15030641 return;
6782 }
6783
6784
2/2
✓ Branch 0 taken 12532802 times.
✓ Branch 1 taken 13428086 times.
25960888 for(int32_t i=0; i<Lwpns.Count(); i++)
6785 {
6786 12532802 sprite *s = Lwpns.spr(i);
6787 12532802 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6788 //if ( itemdbuf[parentitem].flags&ITEM_FLAGS3 ) //can damage Hero
6789 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6790
14/14
✓ Branch 0 taken 741206 times.
✓ Branch 1 taken 11791596 times.
✓ Branch 2 taken 3930246 times.
✓ Branch 3 taken 7861350 times.
✓ Branch 4 taken 3930246 times.
✓ Branch 5 taken 3931104 times.
✓ Branch 6 taken 3877600 times.
✓ Branch 7 taken 53504 times.
✓ Branch 8 taken 3877496 times.
✓ Branch 9 taken 104 times.
✓ Branch 10 taken 91196 times.
✓ Branch 11 taken 3786300 times.
✓ Branch 12 taken 38783 times.
✓ Branch 13 taken 52413 times.
12532802 if((!(itemid==-1&&get_qr(qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & ITEM_FLAG3)))) && scriptcoldet && !fallclk && (!superman || !get_qr(qr_FIREPROOFHERO2)))
6791 {
6792
9/10
✓ Branch 0 taken 3715709 times.
✓ Branch 1 taken 123004 times.
✓ Branch 2 taken 122561 times.
✓ Branch 3 taken 443 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 443 times.
✓ Branch 6 taken 3711 times.
✓ Branch 7 taken 118850 times.
✓ Branch 8 taken 3837822 times.
✓ Branch 9 taken 33 times.
3842009 if(s->id==wFire && (superman ? (diagonalMovement?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6793
1/2
✓ Branch 0 taken 3296 times.
✗ Branch 1 not taken.
4154 (itemid < 0 || itemsbuf[itemid].family!=itype_divinefire))
6794 {
6795 33 std::vector<int32_t> &ev = FFCore.eventData;
6796 33 ev.clear();
6797 33 ev.push_back(lwpn_dp(i)*10000);
6798 33 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6799 33 ev.push_back(0);
6800 33 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6801 33 ev.push_back(48*10000);
6802 33 ev.push_back(ZSD_LWPN*10000);
6803 33 ev.push_back(s->getUID());
6804 33 ev.push_back(ZSD_NONE*10000);
6805 33 ev.push_back(0);
6806
6807 33 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6808 33 int32_t dmg = ev[0]/10000;
6809 33 bool nullhit = ev[2] != 0;
6810
6811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(nullhit) {ev.clear(); return;}
6812
6813 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6814 33 ev[0] = ringpower(dmg)*10000;
6815
6816 33 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6817 33 dmg = ev[0]/10000;
6818 33 int32_t hdir = ev[1]/10000;
6819 33 nullhit = ev[2] != 0;
6820 33 bool divineprot = ev[3] != 0;
6821 33 int32_t iframes = ev[4] / 10000;
6822 33 ev.clear();
6823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(nullhit) return;
6824
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if (Lwpns.spr(i) != s)
6825 {
6826 auto hit = Lwpns.find(s);
6827 if (hit < 0)
6828 s = nullptr;
6829 else
6830 {
6831 s = Lwpns.spr(hit);
6832 i = hit;
6833 }
6834 }
6835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!divineprot)
6836 {
6837
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 game->set_life(zc_max(game->get_life()-dmg,0));
6838 33 weapon* w = (weapon*)s;
6839
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33 if (!get_qr(qr_BROKENHITBY) && w)
6840 {
6841 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6842 if (get_qr(qr_BROKENHITBY))
6843 {
6844 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6845 }
6846 else
6847 {
6848
6849 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getScriptUID());
6850 }
6851 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6852 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6853 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6854 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6855 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].family);
6856 }
6857 33 }
6858
6859 33 hitdir = hdir;
6860
6861
3/6
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 33 times.
33 if (action != rafting && action != freeze && action != sideswimfreeze)
6862 {
6863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (IsSideSwim())
6864 {
6865 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6866 }
6867
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 else if (action == swimming || hopclk == 0xFF)
6868 {
6869 action=swimhit; FFCore.setHeroAction(swimhit);
6870 }
6871 else
6872 {
6873 33 action=gothit; FFCore.setHeroAction(gothit);
6874 }
6875 33 }
6876
6877
5/8
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28 times.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 28 times.
33 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6878 {
6879 5 spins = charging = attackclk = 0;
6880 5 attack=none;
6881 5 tapping = false;
6882 5 }
6883
6884 33 hclk=iframes;
6885 33 sfx(getHurtSFX(),pan(x.getInt()));
6886 33 return;
6887 }
6888 3837822 }
6889
6890 // check enemy weapons true, 1, -1
6891 //
6892
2/2
✓ Branch 0 taken 4177449 times.
✓ Branch 1 taken 493970 times.
4671419 if((itemsbuf[itemid].flags & ITEM_FLAG6))
6893 {
6894
6/6
✓ Branch 0 taken 380644 times.
✓ Branch 1 taken 113326 times.
✓ Branch 2 taken 34343 times.
✓ Branch 3 taken 346301 times.
✓ Branch 4 taken 7231 times.
✓ Branch 5 taken 27112 times.
493970 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6895 {
6896
1/2
✓ Branch 0 taken 140438 times.
✗ Branch 1 not taken.
140438 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6897 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6898 140438 itemid = vbound(itemid, 0, MAXITEMS-1);
6899
6900
2/2
✓ Branch 0 taken 139950 times.
✓ Branch 1 taken 66159 times.
206109 for(int32_t j=0; j<Ewpns.Count(); j++)
6901 {
6902 66159 sprite *t = Ewpns.spr(j);
6903
6904
2/2
✓ Branch 0 taken 65671 times.
✓ Branch 1 taken 488 times.
66159 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6905 {
6906 488 bool reflect = false;
6907 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6908
6909
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 119 times.
488 if(sh_check(itemsbuf[itemid].misc3, itemsbuf[itemid].misc4, t->id, reflect, ((weapon*)t)->type&1, false))
6910 {
6911 119 ((weapon*)s)->dead=1;
6912 119 weapon *ew = ((weapon*)t);
6913 119 int32_t oldid = ew->id;
6914 119 ew->onhit(true, reflect ? 2 : 1, s->dir);
6915 119 }
6916 488 break;
6917 }
6918 65671 }
6919 140438 }
6920 493970 }
6921
6922
6/6
✓ Branch 0 taken 3039952 times.
✓ Branch 1 taken 1631467 times.
✓ Branch 2 taken 741206 times.
✓ Branch 3 taken 2298746 times.
✓ Branch 4 taken 106519 times.
✓ Branch 5 taken 634687 times.
4671419 if((itemsbuf[itemid].flags & ITEM_FLAG2)||(itemid==-1&&get_qr(qr_OUCHBOMBS)))
6923 {
6924
7/8
✓ Branch 0 taken 1692619 times.
✓ Branch 1 taken 45367 times.
✓ Branch 2 taken 45915 times.
✓ Branch 3 taken 1692071 times.
✓ Branch 4 taken 45915 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
✓ Branch 7 taken 45886 times.
1737986 if(((s->id==wBomb)||(s->id==wSBomb)) && !superman && scriptcoldet && !fallclk)
6925 {
6926 45886 weapon* w = (weapon*)s;
6927 45886 bool didhit = s->hit(this);
6928
2/2
✓ Branch 0 taken 45851 times.
✓ Branch 1 taken 35 times.
45886 if(didhit)
6929 {
6930 35 std::vector<int32_t> &ev = FFCore.eventData;
6931 35 ev.clear();
6932
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2 times.
35 ev.push_back(((w->parentitem>-1 ? itemsbuf[w->parentitem].misc3 : w->power) *game->get_hp_per_heart())*10000);
6933 35 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6934 35 ev.push_back(0);
6935 35 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6936 35 ev.push_back(48*10000);
6937 35 ev.push_back(ZSD_LWPN*10000);
6938 35 ev.push_back(w->getUID());
6939 35 ev.push_back(ZSD_NONE*10000);
6940 35 ev.push_back(0);
6941
6942 35 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6943 35 int32_t dmg = ev[0]/10000;
6944 35 bool nullhit = ev[2] != 0;
6945
6946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(nullhit) {ev.clear(); return;}
6947
6948 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6949 35 ev[0] = ringpower(dmg)*10000;
6950
6951 35 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6952 35 dmg = ev[0]/10000;
6953 35 int32_t hdir = ev[1]/10000;
6954 35 nullhit = ev[2] != 0;
6955 35 bool divineprot = ev[3] != 0;
6956 35 int32_t iframes = ev[4] / 10000;
6957 35 ev.clear();
6958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(nullhit) return;
6959
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (Lwpns.spr(i) != w)
6960 {
6961 auto hit = Lwpns.find(w);
6962 if (hit < 0)
6963 s = nullptr;
6964 else
6965 {
6966 s = Lwpns.spr(hit);
6967 i = hit;
6968 }
6969 w = (weapon*)s;
6970 }
6971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!divineprot)
6972 {
6973
5/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 1 times.
35 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6974
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
35 if (!get_qr(qr_BROKENHITBY) && w)
6975 {
6976 1 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (get_qr(qr_BROKENHITBY))
6978 {
6979 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6980 }
6981 else
6982 {
6983
6984 1 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getScriptUID());
6985 }
6986 1 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6987 1 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6988
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6989 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6990 1 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].family);
6991 1 }
6992 35 }
6993
6994 35 hitdir = hdir;
6995
6996
3/6
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
35 if (action != rafting && action != freeze && action != sideswimfreeze)
6997 {
6998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if (IsSideSwim())
6999 {
7000 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7001 }
7002
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 else if (action == swimming || hopclk == 0xFF)
7003 {
7004 action=swimhit; FFCore.setHeroAction(swimhit);
7005 }
7006 else
7007 {
7008 35 action=gothit; FFCore.setHeroAction(gothit);
7009 }
7010 35 }
7011
7012
5/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 34 times.
35 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7013 {
7014 1 spins = charging = attackclk = 0;
7015 1 attack=none;
7016 1 tapping = false;
7017 1 }
7018
7019 35 hclk=iframes;
7020 35 sfx(getHurtSFX(),pan(x.getInt()));
7021 35 return;
7022 }
7023 45851 }
7024 1737951 }
7025
7026
7/8
✓ Branch 0 taken 4671384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9368 times.
✓ Branch 3 taken 4662016 times.
✓ Branch 4 taken 9256 times.
✓ Branch 5 taken 112 times.
✓ Branch 6 taken 4671272 times.
✓ Branch 7 taken 112 times.
4671384 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
7027 {
7028 112 std::vector<int32_t> &ev = FFCore.eventData;
7029 112 ev.clear();
7030 112 ev.push_back(0);
7031 112 ev.push_back(s->dir*10000);
7032 112 ev.push_back(0);
7033 112 ev.push_back(0);
7034 112 ev.push_back(ZSD_LWPN*10000);
7035 112 ev.push_back(s->getUID());
7036 112 ev.push_back(ZSD_NONE*10000);
7037 112 ev.push_back(0);
7038
7039 112 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7040 112 bool nullhit = ev[2] != 0;
7041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(nullhit) {ev.clear(); return;}
7042
7043 112 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7044 112 int32_t hdir = ev[1]/10000;
7045 112 nullhit = ev[2] != 0;
7046 112 ev.clear();
7047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(nullhit) return;
7048
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if (Lwpns.spr(i) != s)
7049 {
7050 auto hit = Lwpns.find(s);
7051 if (hit < 0)
7052 s = nullptr;
7053 else
7054 {
7055 s = Lwpns.spr(hit);
7056 i = hit;
7057 }
7058 }
7059
7060 112 reset_hookshot();
7061 112 xofs=1000;
7062 112 action=inwind; FFCore.setHeroAction(inwind);
7063 112 dir = hdir;
7064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(s) s->dir = hdir;
7065 112 spins = charging = attackclk = 0;
7066
7067 // In case Hero used two whistles in a row, summoning two whirlwinds,
7068 // check which whistle's whirlwind picked him up so the correct
7069 // warp ring will be used
7070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 int32_t whistle=s ? ((weapon*)s)->parentitem : -1;
7071
7072
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
112 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
7073 112 whistleitem=whistle;
7074
7075 112 return;
7076 }
7077 4671272 }
7078
7079
6/8
✓ Branch 0 taken 13315224 times.
✓ Branch 1 taken 112862 times.
✓ Branch 2 taken 13007541 times.
✓ Branch 3 taken 307683 times.
✓ Branch 4 taken 13007541 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 13003674 times.
26431760 if(action==rafting || action==freeze || action==sideswimfreeze ||
7080
5/8
✓ Branch 0 taken 13003674 times.
✓ Branch 1 taken 3867 times.
✓ Branch 2 taken 13003674 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13003674 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13003674 times.
✗ Branch 7 not taken.
13007541 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
7081 424412 return;
7082
7083 13003674 int32_t hit2 = -1;
7084 13003674 do
7085 {
7086
2/2
✓ Branch 0 taken 4170975 times.
✓ Branch 1 taken 8849188 times.
13020163 hit2 = diagonalMovement ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
7087 8849188 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
7088
7089
2/2
✓ Branch 0 taken 12989511 times.
✓ Branch 1 taken 30652 times.
13020163 if(hit2!=-1)
7090 {
7091
2/2
✓ Branch 0 taken 16489 times.
✓ Branch 1 taken 14163 times.
30652 if (hithero(hit2) == 0) return;
7092 16489 }
7093
2/2
✓ Branch 0 taken 16489 times.
✓ Branch 1 taken 12989511 times.
13006000 } while (hit2 != -1);
7094
6/6
✓ Branch 0 taken 12826458 times.
✓ Branch 1 taken 163053 times.
✓ Branch 2 taken 12816135 times.
✓ Branch 3 taken 10323 times.
✓ Branch 4 taken 3203 times.
✓ Branch 5 taken 12812932 times.
12989511 if (superman || !scriptcoldet || fallclk) return;
7095 12812932 hit2 = LwpnHit();
7096
7097
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 12812922 times.
12812932 if(hit2!=-1)
7098 {
7099 10 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
7100 10 std::vector<int32_t> &ev = FFCore.eventData;
7101 10 ev.clear();
7102 10 ev.push_back((lwpn_dp(hit2)*10000));
7103 10 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
7104 10 ev.push_back(0);
7105 10 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7106 10 ev.push_back(48*10000);
7107 10 ev.push_back(ZSD_LWPN*10000);
7108 10 ev.push_back(lwpnspr->getUID());
7109 10 ev.push_back(ZSD_NONE*10000);
7110 10 ev.push_back(0);
7111
7112 10 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7113 10 int32_t dmg = ev[0]/10000;
7114 10 bool nullhit = ev[2] != 0;
7115
7116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nullhit) {ev.clear(); return;}
7117
7118 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7119 10 ev[0] = ringpower(dmg)*10000;
7120
7121 10 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7122 10 dmg = ev[0]/10000;
7123 10 int32_t hdir = ev[1]/10000;
7124 10 nullhit = ev[2] != 0;
7125 10 bool divineprot = ev[3] != 0;
7126 10 int32_t iframes = ev[4] / 10000;
7127 10 ev.clear();
7128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nullhit) return;
7129
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (Lwpns.spr(hit2) != lwpnspr)
7130 {
7131 hit2 = Lwpns.find(lwpnspr);
7132 if (hit2 < 0)
7133 lwpnspr = nullptr;
7134 else lwpnspr = (weapon*)Lwpns.spr(hit2);
7135 }
7136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (!divineprot)
7137 {
7138
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 game->set_life(zc_max(game->get_life() - dmg, 0));
7139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (lwpnspr)
7140 {
7141 10 sethitHeroUID(HIT_BY_LWEAPON, (hit2 + 1));
7142
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
10 if (get_qr(qr_BROKENHITBY))
7143 {
7144 6 sethitHeroUID(HIT_BY_LWEAPON_UID, lwpnspr->getUID());
7145 6 }
7146 else
7147 {
7148
7149 4 sethitHeroUID(HIT_BY_LWEAPON_UID, lwpnspr->getScriptUID());
7150 }
7151 10 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID, lwpnspr->getUID());
7152 10 sethitHeroUID(HIT_BY_LWEAPON_TYPE, lwpnspr->id);
7153
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 if (lwpnspr->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, lwpnspr->parentitem);
7154 8 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
7155 10 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[lwpnspr->parentitem].family);
7156 10 }
7157 10 }
7158
7159 10 hitdir = hdir;
7160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(lwpnspr)
7161 10 lwpnspr->onhit(false);
7162
7163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (IsSideSwim())
7164 {
7165 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7166 }
7167
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 else if(action==swimming || hopclk==0xFF)
7168 {
7169 action=swimhit; FFCore.setHeroAction(swimhit);
7170 }
7171 else
7172 {
7173 10 action=gothit; FFCore.setHeroAction(gothit);
7174 }
7175
7176 10 hclk=iframes;
7177
7178
5/8
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
10 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7179 {
7180 7 spins = charging = attackclk = 0;
7181 7 attack=none;
7182 7 tapping = false;
7183 7 }
7184
7185 10 sfx(getHurtSFX(),pan(x.getInt()));
7186 10 return;
7187 }
7188
7189 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
7190
7191 12812922 hit2 = EwpnHit();
7192
7193
2/2
✓ Branch 0 taken 5414 times.
✓ Branch 1 taken 12807508 times.
12812922 if(hit2!=-1)
7194 {
7195 5414 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
7196 5414 std::vector<int32_t> &ev = FFCore.eventData;
7197 5414 ev.clear();
7198 5414 ev.push_back((ewpn_dp(hit2)*10000));
7199 5414 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
7200 5414 ev.push_back(0);
7201 5414 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7202 5414 ev.push_back(48*10000);
7203 5414 ev.push_back(ZSD_EWPN*10000);
7204 5414 ev.push_back(ewpnspr->getUID());
7205 5414 ev.push_back(ZSD_NONE*10000);
7206 5414 ev.push_back(0);
7207
7208 5414 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7209 5414 int32_t dmg = ev[0]/10000;
7210 5414 bool nullhit = ev[2] != 0;
7211
7212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5414 times.
5414 if(nullhit) {ev.clear(); return;}
7213
7214 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7215 5414 ev[0] = ringpower(dmg)*10000;
7216
7217 5414 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7218 5414 dmg = ev[0]/10000;
7219 5414 int32_t hdir = ev[1]/10000;
7220 5414 nullhit = ev[2] != 0;
7221 5414 bool divineprot = ev[3] != 0;
7222 5414 int32_t iframes = ev[4] / 10000;
7223 5414 ev.clear();
7224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5414 times.
5414 if (nullhit) return;
7225
1/2
✓ Branch 0 taken 5414 times.
✗ Branch 1 not taken.
5414 if (Ewpns.spr(hit2) != ewpnspr)
7226 {
7227 hit2 = Ewpns.find(ewpnspr);
7228 if (hit2 < 0)
7229 ewpnspr = nullptr;
7230 else ewpnspr = (weapon*)Ewpns.spr(hit2);
7231 }
7232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5414 times.
5414 if (!divineprot)
7233 {
7234
2/2
✓ Branch 0 taken 5370 times.
✓ Branch 1 taken 44 times.
5414 game->set_life(zc_max(game->get_life() - dmg, 0));
7235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5414 times.
5414 if (ewpnspr)
7236 {
7237 5414 sethitHeroUID(HIT_BY_EWEAPON, (hit2 + 1));
7238
2/2
✓ Branch 0 taken 5160 times.
✓ Branch 1 taken 254 times.
5414 if (get_qr(qr_BROKENHITBY))
7239 {
7240 5160 sethitHeroUID(HIT_BY_EWEAPON_UID, ewpnspr->getUID());
7241 5160 }
7242 else
7243 {
7244
7245 254 sethitHeroUID(HIT_BY_EWEAPON_UID, ewpnspr->getScriptUID());
7246 }
7247 5414 sethitHeroUID(HIT_BY_EWEAPON_ENGINE_UID, ewpnspr->getUID());
7248 5414 sethitHeroUID(HIT_BY_EWEAPON_TYPE, ewpnspr->id);
7249 5414 }
7250 5414 }
7251
7252 5414 hitdir = hdir;
7253
1/2
✓ Branch 0 taken 5414 times.
✗ Branch 1 not taken.
5414 if(ewpnspr)
7254 5414 ewpnspr->onhit(false);
7255
7256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5414 times.
5414 if (IsSideSwim())
7257 {
7258 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7259 }
7260
3/4
✓ Branch 0 taken 5346 times.
✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5346 times.
5414 else if(action==swimming || hopclk==0xFF)
7261 {
7262 68 action=swimhit; FFCore.setHeroAction(swimhit);
7263 68 }
7264 else
7265 {
7266 5346 action=gothit; FFCore.setHeroAction(gothit);
7267 }
7268
7269 5414 hclk=iframes;
7270
7271
8/8
✓ Branch 0 taken 5383 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 5382 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1932 times.
✓ Branch 5 taken 3450 times.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 1792 times.
5414 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7272 {
7273 3622 spins = charging = attackclk = 0;
7274 3622 attack=none;
7275 3622 tapping = false;
7276 3622 }
7277
7278 5414 sfx(getHurtSFX(),pan(x.getInt()));
7279 5414 return;
7280 }
7281
7282 // The rest of this method deals with damage combos, which can be jumped over.
7283
4/4
✓ Branch 0 taken 12789597 times.
✓ Branch 1 taken 17911 times.
✓ Branch 2 taken 12789850 times.
✓ Branch 3 taken 17658 times.
12807508 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) return;
7284
7285 12789850 int32_t dx1 = (int32_t)x+8-(tmpscr->csensitive);
7286 12789850 int32_t dx2 = (int32_t)x+8+(tmpscr->csensitive-1);
7287
2/2
✓ Branch 0 taken 235293 times.
✓ Branch 1 taken 12554557 times.
12789850 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?tmpscr->csensitive:(tmpscr->csensitive+1)/2);
7288
2/2
✓ Branch 0 taken 235293 times.
✓ Branch 1 taken 12554557 times.
12789850 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?tmpscr->csensitive-1:((tmpscr->csensitive+1)/2)-1);
7289
7290
2/2
✓ Branch 0 taken 12789850 times.
✓ Branch 1 taken 23632124 times.
36421974 for(int32_t i=get_qr(qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
7291 23632124 checkdamagecombos(dx1,dx2,dy1,dy2,i);
7292 14164265 }
7293
7294 16938 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
7295 {
7296 16938 return checkdamagecombos(dx,dx,dy,dy);
7297 }
7298
7299 532 void HeroClass::doHit(int32_t hdir)
7300 {
7301 532 hitdir = hdir;
7302
7303
3/6
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 532 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 532 times.
532 if (action != rafting && action != freeze && action != sideswimfreeze)
7304 {
7305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if (IsSideSwim())
7306 {
7307 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7308 }
7309
2/4
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 532 times.
532 else if (action == swimming || hopclk == 0xFF)
7310 {
7311 action=swimhit; FFCore.setHeroAction(swimhit);
7312 }
7313 else
7314 {
7315 532 action=gothit; FFCore.setHeroAction(gothit);
7316 }
7317 532 }
7318
7319 532 hclk=48;
7320
7321
7/8
✓ Branch 0 taken 530 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 360 times.
✓ Branch 5 taken 170 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 344 times.
532 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7322 {
7323 188 spins = charging = attackclk = 0;
7324 188 attack=none;
7325 188 tapping = false;
7326 188 }
7327
7328 532 sfx(getHurtSFX(),pan(x.getInt()));
7329 532 }
7330
7331 24043476 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
7332 {
7333
5/6
✓ Branch 0 taken 24043210 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 24041019 times.
✓ Branch 3 taken 2191 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24041019 times.
24043476 if(hclk || superman || fallclk)
7334 2457 return false;
7335
7336 24041019 int32_t hp_mod[4] = {0};
7337 int32_t cid[8];
7338 24041019 byte hasKB = 0;
7339
7340 {
7341
2/2
✓ Branch 0 taken 11103581 times.
✓ Branch 1 taken 12937438 times.
24041019 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
7342 24041019 newcombo& cmb = combobuf[cid[0]];
7343
4/4
✓ Branch 0 taken 24041016 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24039197 times.
✓ Branch 3 taken 1819 times.
24041019 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7344 {
7345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1819 times.
1819 if(cmb.usrflags&cflag1)
7346 hp_mod[0] = cmb.attributes[0] / -10000L;
7347 else
7348 1819 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1819 times.
1819 if(!(cmb.usrflags&cflag2))
7350 1819 hasKB |= 1<<0;
7351 1819 }
7352 }
7353 {
7354
2/2
✓ Branch 0 taken 11103581 times.
✓ Branch 1 taken 12937438 times.
24041019 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
7355 24041019 newcombo& cmb = combobuf[cid[1]];
7356
4/4
✓ Branch 0 taken 24041016 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24039151 times.
✓ Branch 3 taken 1865 times.
24041019 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7357 {
7358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1865 times.
1865 if(cmb.usrflags&cflag1)
7359 hp_mod[1] = cmb.attributes[0] / -10000L;
7360 else
7361 1865 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1865 times.
1865 if(!(cmb.usrflags&cflag2))
7363 1865 hasKB |= 1<<1;
7364 1865 }
7365 }
7366 {
7367
2/2
✓ Branch 0 taken 11103581 times.
✓ Branch 1 taken 12937438 times.
24041019 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
7368 24041019 newcombo& cmb = combobuf[cid[2]];
7369
4/4
✓ Branch 0 taken 24041016 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24039190 times.
✓ Branch 3 taken 1826 times.
24041019 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7370 {
7371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
1826 if(cmb.usrflags&cflag1)
7372 hp_mod[2] = cmb.attributes[0] / -10000L;
7373 else
7374 1826 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
1826 if(!(cmb.usrflags&cflag2))
7376 1826 hasKB |= 1<<2;
7377 1826 }
7378 }
7379 {
7380
2/2
✓ Branch 0 taken 11103581 times.
✓ Branch 1 taken 12937438 times.
24041019 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
7381 24041019 newcombo& cmb = combobuf[cid[3]];
7382
4/4
✓ Branch 0 taken 24041016 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24039133 times.
✓ Branch 3 taken 1883 times.
24041019 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7383 {
7384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1883 times.
1883 if(cmb.usrflags&cflag1)
7385 hp_mod[3] = cmb.attributes[0] / -10000L;
7386 else
7387 1883 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1883 times.
1883 if(!(cmb.usrflags&cflag2))
7389 1883 hasKB |= 1<<3;
7390 1883 }
7391 }
7392
7393 24041019 int32_t bestcid=0;
7394 24041019 int best_cpos = -1;
7395 24041019 int32_t hp_modtotal=0;
7396 24041019 int poses[8] = {COMBOPOS(dx1,dy1),COMBOPOS(dx1,dy2),COMBOPOS(dx2,dy1),COMBOPOS(dx2,dy2)};
7397
2/2
✓ Branch 0 taken 17460464 times.
✓ Branch 1 taken 6580555 times.
24041019 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7398
2/2
✓ Branch 0 taken 17452014 times.
✓ Branch 1 taken 6589005 times.
24041019 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7399
2/2
✓ Branch 0 taken 17460490 times.
✓ Branch 1 taken 6580529 times.
24041019 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7400
2/2
✓ Branch 0 taken 17452040 times.
✓ Branch 1 taken 6588979 times.
24041019 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7401
7402
2/2
✓ Branch 0 taken 48082038 times.
✓ Branch 1 taken 24041019 times.
72123057 for (int32_t i = 0; i <= 1; ++i)
7403 {
7404
2/2
✓ Branch 0 taken 31423695 times.
✓ Branch 1 taken 16658343 times.
48082038 if(tmpscr2[i].valid!=0)
7405 {
7406
2/2
✓ Branch 0 taken 13156917 times.
✓ Branch 1 taken 3501426 times.
16658343 if (get_qr(qr_OLD_BRIDGE_COMBOS))
7407 {
7408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7409
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7410
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7411
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7412 13156917 }
7413 else
7414 {
7415
4/4
✓ Branch 0 taken 10124 times.
✓ Branch 1 taken 3491302 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 7586 times.
3501426 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7416
4/4
✓ Branch 0 taken 10154 times.
✓ Branch 1 taken 3491272 times.
✓ Branch 2 taken 2598 times.
✓ Branch 3 taken 7556 times.
3501426 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7417
4/4
✓ Branch 0 taken 10148 times.
✓ Branch 1 taken 3491278 times.
✓ Branch 2 taken 2622 times.
✓ Branch 3 taken 7526 times.
3501426 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7418
4/4
✓ Branch 0 taken 10181 times.
✓ Branch 1 taken 3491245 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 7496 times.
3501426 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7419 }
7420 16658343 }
7421 48082038 }
7422
7423
2/2
✓ Branch 0 taken 96164076 times.
✓ Branch 1 taken 24041019 times.
120205095 for(int32_t i=0; i<4; i++)
7424 {
7425
2/2
✓ Branch 0 taken 37140136 times.
✓ Branch 1 taken 59023940 times.
96164076 if(get_qr(qr_DMGCOMBOPRI))
7426 {
7427
2/2
✓ Branch 0 taken 37139750 times.
✓ Branch 1 taken 386 times.
37140136 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
7428 {
7429
2/2
✓ Branch 0 taken 37139592 times.
✓ Branch 1 taken 158 times.
37139750 if(hp_mod[i] < hp_modtotal)
7430 {
7431 158 hp_modtotal = hp_mod[i];
7432 158 bestcid = cid[i];
7433 158 best_cpos = poses[i];
7434 158 }
7435 37139750 }
7436
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 88 times.
386 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
7437 {
7438
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 if(hp_mod[i] > hp_modtotal)
7439 {
7440 hp_modtotal = hp_mod[i];
7441 bestcid = cid[i];
7442 best_cpos = poses[i];
7443 }
7444 298 }
7445 37140136 }
7446
2/2
✓ Branch 0 taken 59022016 times.
✓ Branch 1 taken 1924 times.
59023940 else if(hp_mod[i] < hp_modtotal)
7447 {
7448 1924 hp_modtotal = hp_mod[i];
7449 1924 bestcid = cid[i];
7450 1924 best_cpos = poses[i];
7451 1924 }
7452 96164076 }
7453
7454 {
7455 24041019 poses[4] = getFFCAt(dx1,dy1);
7456
2/2
✓ Branch 0 taken 384712 times.
✓ Branch 1 taken 23656307 times.
24041019 cid[4] = poses[4] > -1 ? tmpscr->ffcs[poses[4]].data : 0;
7457 24041019 newcombo& cmb = combobuf[cid[4]];
7458
4/4
✓ Branch 0 taken 24040824 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 24040773 times.
✓ Branch 3 taken 51 times.
24041019 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7459 {
7460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(cmb.usrflags&cflag1 )
7461 hp_mod[0] = cmb.attributes[0]/10000L;
7462 else
7463 51 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(!(cmb.usrflags&cflag2))
7465 51 hasKB |= 1<<4;
7466 51 }
7467 }
7468 {
7469 24041019 poses[5] = getFFCAt(dx1,dy2);
7470
2/2
✓ Branch 0 taken 381713 times.
✓ Branch 1 taken 23659306 times.
24041019 cid[5] = poses[5] > -1 ? tmpscr->ffcs[poses[5]].data : 0;
7471 24041019 newcombo& cmb = combobuf[cid[5]];
7472
4/4
✓ Branch 0 taken 24040815 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 24040768 times.
✓ Branch 3 taken 47 times.
24041019 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7473 {
7474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(cmb.usrflags&cflag1 )
7475 hp_mod[1] = cmb.attributes[0]/10000L;
7476 else
7477 47 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(!(cmb.usrflags&cflag2))
7479 47 hasKB |= 1<<5;
7480 47 }
7481 }
7482 {
7483 24041019 poses[6] = getFFCAt(dx2,dy1);
7484
2/2
✓ Branch 0 taken 388802 times.
✓ Branch 1 taken 23652217 times.
24041019 cid[6] = poses[6] > -1 ? tmpscr->ffcs[poses[6]].data : 0;
7485 24041019 newcombo& cmb = combobuf[cid[6]];
7486
4/4
✓ Branch 0 taken 24040827 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 24040780 times.
✓ Branch 3 taken 47 times.
24041019 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7487 {
7488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(cmb.usrflags&cflag1 )
7489 hp_mod[2] = cmb.attributes[0]/10000L;
7490 else
7491 47 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(!(cmb.usrflags&cflag2))
7493 47 hasKB |= 1<<6;
7494 47 }
7495 }
7496 {
7497 24041019 poses[7] = getFFCAt(dx2,dy2);
7498
2/2
✓ Branch 0 taken 385761 times.
✓ Branch 1 taken 23655258 times.
24041019 cid[7] = poses[7] > -1 ? tmpscr->ffcs[poses[7]].data : 0;
7499 24041019 newcombo& cmb = combobuf[cid[7]];
7500
4/4
✓ Branch 0 taken 24040818 times.
✓ Branch 1 taken 201 times.
✓ Branch 2 taken 24040773 times.
✓ Branch 3 taken 45 times.
24041019 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7501 {
7502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(cmb.usrflags&cflag1 )
7503 hp_mod[3] = cmb.attributes[0]/10000L;
7504 else
7505 45 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!(cmb.usrflags&cflag2))
7507 45 hasKB |= 1<<7;
7508 45 }
7509 }
7510
7511 24041019 int32_t bestffccid = 0;
7512 24041019 int best_ffcpos = -1;
7513 24041019 int32_t hp_modtotalffc = 0;
7514
7515
2/2
✓ Branch 0 taken 48082038 times.
✓ Branch 1 taken 24041019 times.
72123057 for (int32_t i = 0; i <= 1; ++i)
7516 {
7517
2/2
✓ Branch 0 taken 31423695 times.
✓ Branch 1 taken 16658343 times.
48082038 if(tmpscr2[i].valid!=0)
7518 {
7519
2/2
✓ Branch 0 taken 13156917 times.
✓ Branch 1 taken 3501426 times.
16658343 if (get_qr(qr_OLD_BRIDGE_COMBOS))
7520 {
7521
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7522
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7523
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13156917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13156917 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7525 13156917 }
7526 else
7527 {
7528
4/4
✓ Branch 0 taken 10124 times.
✓ Branch 1 taken 3491302 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 7586 times.
3501426 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7529
4/4
✓ Branch 0 taken 10154 times.
✓ Branch 1 taken 3491272 times.
✓ Branch 2 taken 2598 times.
✓ Branch 3 taken 7556 times.
3501426 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7530
4/4
✓ Branch 0 taken 10148 times.
✓ Branch 1 taken 3491278 times.
✓ Branch 2 taken 2622 times.
✓ Branch 3 taken 7526 times.
3501426 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7531
4/4
✓ Branch 0 taken 10181 times.
✓ Branch 1 taken 3491245 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 7496 times.
3501426 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7532 }
7533 16658343 }
7534 48082038 }
7535
7536
2/2
✓ Branch 0 taken 96164076 times.
✓ Branch 1 taken 24041019 times.
120205095 for(int32_t i=0; i<4; i++)
7537 {
7538
2/2
✓ Branch 0 taken 1540988 times.
✓ Branch 1 taken 94623088 times.
96164076 if(poses[i+4] < 0) continue;
7539
2/2
✓ Branch 0 taken 224021 times.
✓ Branch 1 taken 1316967 times.
1540988 if(get_qr(qr_DMGCOMBOPRI))
7540 {
7541
2/2
✓ Branch 0 taken 223905 times.
✓ Branch 1 taken 116 times.
224021 if(hp_modtotalffc >= 0)
7542 {
7543
2/2
✓ Branch 0 taken 223840 times.
✓ Branch 1 taken 65 times.
223905 if(hp_mod[i] < hp_modtotalffc)
7544 {
7545 65 hp_modtotalffc = hp_mod[i];
7546 65 bestffccid = cid[4+i];
7547 65 best_ffcpos = poses[4+i];
7548 65 }
7549 223905 }
7550
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 112 times.
116 else if(hp_mod[i] < 0)
7551 {
7552
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(hp_mod[i] > hp_modtotalffc)
7553 {
7554 hp_modtotalffc = hp_mod[i];
7555 bestffccid = cid[4+i];
7556 best_ffcpos = poses[4+i];
7557 }
7558 112 }
7559 224021 }
7560
2/2
✓ Branch 0 taken 1316938 times.
✓ Branch 1 taken 29 times.
1316967 else if(hp_mod[i] < hp_modtotalffc)
7561 {
7562 29 hp_modtotalffc = hp_mod[i];
7563 29 bestffccid = cid[4+i];
7564 29 best_ffcpos = poses[4+i];
7565 29 }
7566 1540988 }
7567
7568
2/2
✓ Branch 0 taken 2058 times.
✓ Branch 1 taken 24038961 times.
24041019 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7569 24041019 int best_type = 0;
7570
2/2
✓ Branch 0 taken 24040949 times.
✓ Branch 1 taken 70 times.
24041019 if(hp_modtotalffc < hp_modtotal)
7571 {
7572 70 bestcid = bestffccid;
7573 70 best_type = 1;
7574 70 }
7575
7576 24041019 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & ITEM_FLAG1));
7577 24041019 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & ITEM_FLAG1));
7578 24041019 bool current_ring = ((tmpscr->flags6&fTOGGLERINGDAMAGE) != 0);
7579
1/2
✓ Branch 0 taken 24041019 times.
✗ Branch 1 not taken.
24041019 if(current_ring)
7580 {
7581 global_defring = !global_defring;
7582 global_perilring = !global_perilring;
7583 }
7584 24041019 int32_t itemid = current_item_id(itype_boots);
7585
7586
2/2
✓ Branch 0 taken 23205171 times.
✓ Branch 1 taken 835848 times.
24041019 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & ITEM_FLAG1);
7587
2/2
✓ Branch 0 taken 23205171 times.
✓ Branch 1 taken 835848 times.
24041019 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & ITEM_FLAG3);
7588
7589
2/2
✓ Branch 0 taken 24038877 times.
✓ Branch 1 taken 2142 times.
24041019 if(hp_modmin<0)
7590 {
7591
10/14
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 528 times.
✓ Branch 2 taken 1614 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1614 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1614 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 1609 times.
✓ Branch 10 taken 1614 times.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1614 times.
2142 if((itemid<0) || ignoreBoots || (tmpscr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7592 {
7593
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 6 times.
538 if (!do_health_check) return true;
7594 532 std::vector<int32_t> &ev = FFCore.eventData;
7595 532 ev.clear();
7596 532 ev.push_back(-hp_modmin*10000);
7597
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 ev.push_back((hasKB ? dir^1 : -1)*10000);
7598 532 ev.push_back(0);
7599 532 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7600 532 ev.push_back(48*10000);
7601 532 ev.push_back(ZSD_COMBODATA*10000);
7602 532 ev.push_back(bestcid);
7603 532 ev.push_back((best_type ? ZSD_FFC : ZSD_COMBOPOS)*10000);
7604
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 462 times.
532 ev.push_back(best_type ? best_ffcpos : best_cpos*10000);
7605
7606 532 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7607 532 int32_t dmg = ev[0]/10000;
7608 532 bool nullhit = ev[2] != 0;
7609
7610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(nullhit) {ev.clear(); return false;}
7611
7612 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7613 532 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7614
7615 532 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7616 532 dmg = ev[0]/10000;
7617 532 int32_t hdir = ev[1]/10000;
7618 532 nullhit = ev[2] != 0;
7619 532 bool divineprot = ev[3] != 0;
7620 532 int32_t iframes = ev[4] / 10000;
7621 532 ev.clear();
7622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(nullhit) return false;
7623
7624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(!divineprot)
7625 {
7626
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 19 times.
532 game->set_life(zc_max(game->get_life()-dmg,0));
7627 532 }
7628
7629 532 hitdir = hdir;
7630 532 doHit(hitdir);
7631 532 hclk = iframes;
7632 532 return true;
7633 }
7634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1614 times.
1614 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7635 1614 }
7636
7637 24040491 return false;
7638 24043486 }
7639
7640 30809 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7641 {
7642
1/2
✓ Branch 0 taken 30809 times.
✗ Branch 1 not taken.
30809 if(force_hdir > 3) force_hdir = -1;
7643 30809 enemy* enemyptr = (enemy*)guys.spr(hit2);
7644
1/2
✓ Branch 0 taken 30809 times.
✗ Branch 1 not taken.
30809 if(!enemyptr) return 0;
7645 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7646 30809 int32_t stompid = current_item_id(itype_stompboots);
7647
5/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 30794 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
30809 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7648
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7649
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7650 {
7651 paymagiccost(stompid);
7652 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7653
7654 if(itemsbuf[stompid].flags & ITEM_FLAG1)
7655 {
7656 fall = -(itemsbuf[stompid].misc1);
7657 }
7658
7659 if(itemsbuf[stompid].flags & ITEM_DOWNGRADE)
7660 game->set_item(stompid,false);
7661
7662 // Stomp Boots script
7663 if(itemsbuf[stompid].script != 0 && !(FFCore.doscript(ScriptType::Item, stompid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
7664 {
7665 int i = stompid;
7666 FFCore.reset_script_engine_data(ScriptType::Item, i);
7667 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[stompid].script, i);
7668 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
7669 }
7670
7671 return -1;
7672 }
7673
6/6
✓ Branch 0 taken 26548 times.
✓ Branch 1 taken 4261 times.
✓ Branch 2 taken 25760 times.
✓ Branch 3 taken 788 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 25713 times.
30809 else if(superman || !scriptcoldet || fallclk)
7674 5096 return 0;
7675 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7676 //!Add a flag check to this if:
7677
5/6
✓ Branch 0 taken 9372 times.
✓ Branch 1 taken 16341 times.
✓ Branch 2 taken 9372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2607 times.
✓ Branch 5 taken 6765 times.
25715 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7678
4/4
✓ Branch 0 taken 2362 times.
✓ Branch 1 taken 245 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 9125 times.
9372 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7679 {
7680 16586 return -1;
7681 }
7682
7683 9127 std::vector<int32_t> &ev = FFCore.eventData;
7684 9127 ev.clear();
7685 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7686 9127 ev.push_back((enemy_dp(hit2) *10000));
7687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9127 times.
9127 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7688 9127 ev.push_back(0);
7689 9127 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7690 9127 ev.push_back(48*10000);
7691 9127 ev.push_back(ZSD_NPC*10000);
7692 9127 ev.push_back(enemyptr->getUID());
7693 9127 ev.push_back(ZSD_NONE*10000);
7694 9127 ev.push_back(0);
7695
7696 9127 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7697 9127 int32_t dmg = ev[0] / 10000;
7698 9127 bool nullhit = ev[2] != 0;
7699
7700
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9126 times.
9127 if(nullhit) {ev.clear(); return -1;}
7701
7702 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7703 9126 ev[0] = ((ringpower(dmg)*10000));
7704
7705 9126 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7706 9126 dmg = ev[0] / 10000;
7707 9126 int32_t hdir = ev[1] / 10000;
7708 9126 nullhit = ev[2] != 0;
7709 9126 bool divineprot = ev[3] != 0;
7710 9126 int32_t iframes = ev[4] / 10000;
7711 9126 ev.clear();
7712
7713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9126 times.
9126 if(nullhit) return -1;
7714
7715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9126 times.
9126 if(!divineprot)
7716 {
7717
2/2
✓ Branch 0 taken 9072 times.
✓ Branch 1 taken 54 times.
9126 game->set_life(zc_max(game->get_life()-dmg,0));
7718 9126 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7719 9126 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7720
2/2
✓ Branch 0 taken 8889 times.
✓ Branch 1 taken 237 times.
9126 if (get_qr(qr_BROKENHITBY))
7721 {
7722 8889 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7723 8889 }
7724 else
7725 {
7726 237 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->script_UID);
7727 }
7728 9126 sethitHeroUID(HIT_BY_NPC_ENGINE_UID,enemyptr->getUID());
7729 9126 sethitHeroUID(HIT_BY_NPC_ID, enemyptr->id);
7730 9126 sethitHeroUID(HIT_BY_NPC_TYPE, enemyptr->family);
7731 9126 }
7732
7733 9126 hitdir = hdir;
7734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9126 times.
9126 if (IsSideSwim())
7735 {
7736 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7737 }
7738
3/4
✓ Branch 0 taken 9056 times.
✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9056 times.
9126 else if(action==swimming || hopclk==0xFF)
7739 {
7740 70 action=swimhit; FFCore.setHeroAction(swimhit);
7741 70 }
7742 else
7743 {
7744 9056 action=gothit; FFCore.setHeroAction(gothit);
7745 }
7746
7747 9126 hclk=iframes;
7748 9126 sfx(getHurtSFX(),pan(x.getInt()));
7749
7750
8/8
✓ Branch 0 taken 9102 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 9099 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3752 times.
✓ Branch 5 taken 5347 times.
✓ Branch 6 taken 158 times.
✓ Branch 7 taken 3594 times.
9126 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7751 {
7752 5532 spins = charging = attackclk = 0;
7753 5532 attack=none;
7754 5532 tapping = false;
7755 5532 }
7756
7757 9126 enemy_scored(hit2);
7758 9126 int32_t dm7 = enemyptr->dmisc7;
7759 9126 int32_t dm8 = enemyptr->dmisc8;
7760
7761
3/3
✓ Branch 0 taken 4445 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 4672 times.
9126 switch(enemyptr->family)
7762 {
7763 case eeWALLM:
7764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(enemyptr->hp>0)
7765 {
7766 9 GrabHero(hit2);
7767 9 inwallm=true;
7768 9 action=none; FFCore.setHeroAction(none);
7769 9 }
7770 9 break;
7771
7772 //case eBUBBLEST:
7773 //case eeBUBBLE:
7774 case eeWALK:
7775 {
7776 4672 int32_t itemid = current_item_id(itype_whispring);
7777 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7778
3/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 3797 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 875 times.
4672 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7779
3/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 3797 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 875 times.
4672 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7780
7781
7/7
✓ Branch 0 taken 3791 times.
✓ Branch 1 taken 448 times.
✓ Branch 2 taken 145 times.
✓ Branch 3 taken 256 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 6 times.
4672 switch(dm7)
7782 {
7783 case e7tTEMPJINX:
7784
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 398 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 48 times.
448 if(dm8==0 || dm8==2)
7785
4/4
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 386 times.
786 if(swordclk>=0 && !(sworddivisor==0))
7786 386 swordclk=150;
7787
7788
4/4
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 398 times.
448 if(dm8==1 || dm8==2)
7789
3/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 49 times.
99 if(itemclk>=0 && !(itemdivisor==0))
7790 49 itemclk=150;
7791
7792 448 break;
7793
7794 case e7tPERMJINX:
7795
3/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
145 if(dm8==0 || dm8==2)
7796
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 93 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
99 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/sworddivisor) : -1;
7797
7798
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
145 if(dm8==1 || dm8==2)
7799
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
46 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/itemdivisor) : -1;
7800
7801 145 break;
7802
7803 case e7tUNJINX:
7804
4/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 57 times.
256 if(dm8==0 || dm8==2)
7805 199 swordclk=0;
7806
7807
4/4
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 180 times.
256 if(dm8==1 || dm8==2)
7808 76 itemclk=0;
7809
7810 256 break;
7811
7812 case e7tTAKEMAGIC:
7813 5 game->change_dmagic(-dm8*game->get_magicdrainrate());
7814 5 break;
7815
7816 case e7tTAKERUPEES:
7817 21 game->change_drupy(-dm8);
7818 21 break;
7819
7820 case e7tDRUNK:
7821 6 drunkclk += dm8;
7822 6 break;
7823 }
7824 4672 verifyAWpn();
7825
2/2
✓ Branch 0 taken 4534 times.
✓ Branch 1 taken 138 times.
4672 if(dm7 >= e7tEATITEMS)
7826 {
7827 138 EatHero(hit2);
7828 138 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7829 138 action=none; FFCore.setHeroAction(none);
7830 138 }
7831 }
7832 4672 }
7833 9126 return 0;
7834 30809 }
7835
7836 513540 void HeroClass::addsparkle(int32_t wpn)
7837 {
7838 //return;
7839 513540 weapon *w = (weapon*)Lwpns.spr(wpn);
7840 513540 int32_t itemid = w->parentitem;
7841
7842
2/2
✓ Branch 0 taken 508039 times.
✓ Branch 1 taken 5501 times.
513540 if(itemid<0)
7843 5501 return;
7844
7845 508039 int32_t itemtype = itemsbuf[itemid].family;
7846
7847
4/4
✓ Branch 0 taken 507966 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 127013 times.
✓ Branch 3 taken 380953 times.
508039 if(itemtype!=itype_cbyrna && frame%4)
7848 380953 return;
7849
7850
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 127013 times.
127086 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7851
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 127013 times.
127086 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7852 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7853
5/8
✓ Branch 0 taken 37740 times.
✓ Branch 1 taken 89346 times.
✓ Branch 2 taken 69175 times.
✓ Branch 3 taken 20171 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 37740 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
127086 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7854 127086 int32_t direction=w->dir;
7855
7856
2/2
✓ Branch 0 taken 69175 times.
✓ Branch 1 taken 57911 times.
127086 if(sparkle_type)
7857 {
7858 57911 int32_t h=0;
7859 57911 int32_t v=0;
7860
7861
6/6
✓ Branch 0 taken 45738 times.
✓ Branch 1 taken 12173 times.
✓ Branch 2 taken 40646 times.
✓ Branch 3 taken 5092 times.
✓ Branch 4 taken 7702 times.
✓ Branch 5 taken 32944 times.
57911 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7862 {
7863 24967 h=-1;
7864 24967 }
7865
7866
6/6
✓ Branch 0 taken 46118 times.
✓ Branch 1 taken 11793 times.
✓ Branch 2 taken 39436 times.
✓ Branch 3 taken 6682 times.
✓ Branch 4 taken 5665 times.
✓ Branch 5 taken 33771 times.
57911 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7867 {
7868 24140 h=1;
7869 24140 }
7870
7871
6/6
✓ Branch 0 taken 54012 times.
✓ Branch 1 taken 3899 times.
✓ Branch 2 taken 48347 times.
✓ Branch 3 taken 5665 times.
✓ Branch 4 taken 7702 times.
✓ Branch 5 taken 40645 times.
57911 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7872 {
7873 17266 v=-1;
7874 17266 }
7875
7876
6/6
✓ Branch 0 taken 53006 times.
✓ Branch 1 taken 4905 times.
✓ Branch 2 taken 46324 times.
✓ Branch 3 taken 6682 times.
✓ Branch 4 taken 5092 times.
✓ Branch 5 taken 41232 times.
57911 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7877 {
7878 16679 v=1;
7879 16679 }
7880
7881 // Damaging boomerang sparkle?
7882
3/4
✓ Branch 0 taken 20171 times.
✓ Branch 1 taken 37740 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20171 times.
57911 if(wpn3 && itemtype==itype_brang)
7883 {
7884 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7885 // whatever it just bounced off of if it's shielded from that direction.
7886
6/6
✓ Branch 0 taken 13173 times.
✓ Branch 1 taken 6998 times.
✓ Branch 2 taken 12323 times.
✓ Branch 3 taken 850 times.
✓ Branch 4 taken 5333 times.
✓ Branch 5 taken 6990 times.
20171 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7887 6990 direction=oppositeDir[direction];
7888 20171 }
7889
4/4
✓ Branch 0 taken 53638 times.
✓ Branch 1 taken 4273 times.
✓ Branch 2 taken 23899 times.
✓ Branch 3 taken 29739 times.
57911 if(itemtype==itype_brang && get_qr(qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7890
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 57838 times.
57911 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7891
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 57838 times.
57911 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7892
5/10
✓ Branch 0 taken 57911 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57911 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57911 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 57911 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 57911 times.
✗ Branch 9 not taken.
57911 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7893 57911 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7894 57911 }
7895 513540 }
7896
7897 // For wPhantoms
7898 7410 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7899 {
7900
2/2
✓ Branch 0 taken 5586 times.
✓ Branch 1 taken 1824 times.
7410 if(frame%4) return;
7901
7902 1824 int32_t arrow = -1;
7903
7904
2/2
✓ Branch 0 taken 1520 times.
✓ Branch 1 taken 10041 times.
11561 for(int32_t i=0; i<Lwpns.Count(); i++)
7905 {
7906 10041 weapon *w = (weapon*)Lwpns.spr(i);
7907
7908
4/4
✓ Branch 0 taken 6249 times.
✓ Branch 1 taken 3792 times.
✓ Branch 2 taken 5945 times.
✓ Branch 3 taken 304 times.
10041 if(w->id == wPhantom && w->type == type1)
7909 {
7910 304 arrow = i;
7911 304 break;
7912 }
7913 9737 }
7914
7915
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 1520 times.
1824 if(arrow==-1)
7916 {
7917 1520 return;
7918 }
7919
7920 304 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7921 304 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7922
6/12
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 304 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 304 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 304 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 304 times.
✗ Branch 11 not taken.
304 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7923 7410 }
7924
7925 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7926 14162639 void HeroClass::PhantomsCleanup()
7927 {
7928
2/2
✓ Branch 0 taken 14161405 times.
✓ Branch 1 taken 1234 times.
14162639 if(Lwpns.idCount(wPhantom))
7929 {
7930
2/2
✓ Branch 0 taken 8023 times.
✓ Branch 1 taken 1234 times.
9257 for(int32_t i=0; i<Lwpns.Count(); i++)
7931 {
7932 8023 weapon *w = ((weapon *)Lwpns.spr(i));
7933
3/4
✓ Branch 0 taken 4869 times.
✓ Branch 1 taken 3154 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4869 times.
8023 if ( w->id == wPhantom && !w->isScriptGenerated() )
7934 {
7935
4/8
✓ Branch 0 taken 4869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4869 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4869 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4869 times.
4869 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7936 {
7937 Lwpns.remove(w);
7938 }
7939 4869 }
7940 8023 }
7941 1234 }
7942 14162639 }
7943
7944 //Waitframe handler for refilling operations
7945 6288 static void do_refill_waitframe()
7946 {
7947 6288 put_passive_subscr(framebuf,0,passive_subscreen_offset,game->should_show_time(),sspUP);
7948
1/2
✓ Branch 0 taken 6288 times.
✗ Branch 1 not taken.
6288 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7949 {
7950 script_drawing_commands.Clear();
7951 if(DMaps[currdmap].passive_sub_script != 0)
7952 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
7953
7954 if (FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && DMaps[currdmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen))
7955 {
7956 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
7957 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
7958 }
7959 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
7960 }
7961 6288 advanceframe(true);
7962 6288 }
7963 //Special handler if it's a "fairy revive"
7964 static void do_death_refill_waitframe()
7965 {
7966 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7967 //This script should be able to draw a 'fairy saving the player' animation -Em
7968 do_refill_waitframe();
7969 }
7970
7971 1 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7972 {
7973 1 int32_t found_unowned = -1;
7974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
153 for(int q = 0; q < MAXITEMS; ++q)
7975 {
7976
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 152 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
153 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7977 {
7978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_item(q))
7979 1 return q;
7980 if(unowned)
7981 found_unowned = q;
7982 }
7983 152 }
7984 return found_unowned;
7985 1 }
7986
7987 int32_t getPushDir(int32_t flag)
7988 {
7989 switch(flag)
7990 {
7991 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7992 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7993 case mfPUSHUINS:
7994 return up;
7995 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7996 return down;
7997 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7998 case mfPUSHLRINS: case mfPUSHLINS:
7999 return left;
8000 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8001 return right;
8002 }
8003 return -1;
8004 }
8005
8006 void post_item_collect();
8007
8008 14164267 bool HeroClass::handle_portal_collide(portal* p)
8009 {
8010
1/2
✓ Branch 0 taken 14164267 times.
✗ Branch 1 not taken.
14164267 if(!p) return false;
8011 14164267 p->animate(0);
8012
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14164267 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14164267 if(p->destdmap < 0 || p->destdmap >= MAXDMAPS)
8013 14164267 return false;
8014 if(abs(x - p->x) < 12
8015 && abs(y - p->y) < 12)
8016 {
8017 if(p->prox_active)
8018 {
8019 //Store some values to restore if 'warp fails'
8020 int32_t tLastEntrance = lastentrance,
8021 tLastEntranceDMap = lastentrance_dmap,
8022 tContScr = game->get_continue_scrn(),
8023 tContDMap = game->get_continue_dmap();
8024 int32_t sourcescr = currscr, sourcedmap = currdmap;
8025 zfix tx = x, ty = y, tz = z;
8026 x = p->x;
8027 y = p->y;
8028
8029 int32_t weff = p->weffect,
8030 wsfx = p->wsfx;
8031
8032 int32_t savep = p->saved_data;
8033 //After this line, 'p' becomes INVALID!
8034 FFCore.warp_player(wtIWARP, p->destdmap, p->destscr,
8035 -1, -1, weff, wsfx, 0, -1);
8036
8037 if(mirrorBonk()) //Invalid landing, warp back!
8038 {
8039 action = none; FFCore.setHeroAction(none);
8040 lastentrance = tLastEntrance;
8041 lastentrance_dmap = tLastEntranceDMap;
8042 game->set_continue_scrn(tContScr);
8043 game->set_continue_dmap(tContDMap);
8044 x = tx;
8045 y = ty;
8046 z = tz;
8047 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
8048 wsfx, 0, -1);
8049 handle_portal_prox(&mirror_portal);
8050 portals.forEach([&](sprite& p)
8051 {
8052 handle_portal_prox((portal*)&p);
8053 return false;
8054 });
8055 }
8056 else game->clear_portal(savep); //Remove portal once used
8057 return true;
8058 }
8059 }
8060 else p->prox_active = true;
8061 return false;
8062 14164267 }
8063 147 void HeroClass::handle_portal_prox(portal* p)
8064 {
8065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(!p) return;
8066
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 23 times.
147 p->prox_active = !(abs(x - p->x) < 12 && abs(y - p->y) < 12);
8067 147 }
8068 // returns true when game over
8069 41870039 bool HeroClass::animate(int32_t)
8070 {
8071 41870039 int32_t lsave=0;
8072
1/2
✓ Branch 0 taken 41870039 times.
✗ Branch 1 not taken.
41870039 if(immortal > 0)
8073 --immortal;
8074 41870039 prompt_combo = 0;
8075
2/2
✓ Branch 0 taken 27706395 times.
✓ Branch 1 taken 14163644 times.
41870039 if (onpassivedmg)
8076 {
8077 27706395 onpassivedmg=false;
8078 27706395 }
8079
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 14163639 times.
14163644 else if (damageovertimeclk)
8080 {
8081 5 damageovertimeclk = 0;
8082 5 }
8083
8084
2/2
✓ Branch 0 taken 41858974 times.
✓ Branch 1 taken 11065 times.
41870039 if(lift_wpn)
8085 {
8086 11065 auto oldid = lift_wpn->id;
8087
2/2
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 10142 times.
11065 switch(lift_wpn->id)
8088 {
8089 case wLitBomb:
8090 case wBomb:
8091 case wLitSBomb:
8092 case wSBomb:
8093
2/4
✓ Branch 0 taken 923 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 923 times.
923 if(lift_wpn->misc && get_qr(qr_HELD_BOMBS_EXPLODE)) //timed fuse
8094 {
8095 923 lift_wpn->limited_animate();
8096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 923 times.
923 if(lift_wpn->id != oldid)
8097 {
8098 lift_wpn->moveflags &= ~FLAG_OBEYS_GRAV;
8099 drop_liftwpn();
8100 goto heroanimate_skip_liftwpn;
8101 }
8102 923 ++lift_wpn->clk;
8103 923 }
8104 923 break;
8105 }
8106
1/2
✓ Branch 0 taken 11065 times.
✗ Branch 1 not taken.
11065 if(lift_wpn->dead>0)
8107 --lift_wpn->dead;
8108
8109
1/2
✓ Branch 0 taken 11065 times.
✗ Branch 1 not taken.
11065 if(lift_wpn->dead==0)
8110 {
8111 if(lift_wpn->death_spawnitem > -1)
8112 {
8113 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, lift_wpn->death_spawnitem, lift_wpn->death_item_pflags, 0));
8114 itm->fakez = lift_wpn->fakez;
8115 items.add(itm);
8116 }
8117 if(lift_wpn->death_spawndropset > -1)
8118 {
8119 auto itid = select_dropitem(lift_wpn->death_spawndropset);
8120 if(itid > -1)
8121 {
8122 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, itid, lift_wpn->death_item_pflags, 0));
8123 itm->fakez = lift_wpn->fakez;
8124 itm->from_dropset = lift_wpn->death_spawndropset;
8125 items.add(itm);
8126 }
8127 }
8128 switch(lift_wpn->death_sprite)
8129 {
8130 case -2: decorations.add(new dBushLeaves(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dBUSHLEAVES, 0, 0)); break;
8131 case -3: decorations.add(new dFlowerClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dFLOWERCLIPPINGS, 0, 0)); break;
8132 case -4: decorations.add(new dGrassClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dGRASSCLIPPINGS, 0, 0)); break;
8133 default:
8134 if(lift_wpn->death_sprite < 0) break;
8135 decorations.add(new comboSprite(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dCOMBOSPRITE, 0, lift_wpn->death_sprite));
8136 }
8137 if(lift_wpn->death_sfx > 0)
8138 sfx(lift_wpn->death_sfx, pan(int32_t(lift_wpn->x)));
8139 delete lift_wpn;
8140 lift_wpn = nullptr;
8141 }
8142 heroanimate_skip_liftwpn:;
8143 11065 }
8144
8145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41870039 times.
41870039 if(cheats_execute_goto)
8146 {
8147 didpit=true;
8148 pitx=x;
8149 pity=y;
8150 dowarp(3,0);
8151 cheats_execute_goto=false;
8152 solid_update(false);
8153 return false;
8154 }
8155
8156
1/2
✓ Branch 0 taken 41870039 times.
✗ Branch 1 not taken.
41870039 if(cheats_execute_light)
8157 {
8158 toggle_lights(pal_litOVERRIDE); //Forcibly set permLit, overriding its current setting
8159 cheats_execute_light = false;
8160 }
8161
8162
3/4
✓ Branch 0 taken 14164267 times.
✓ Branch 1 taken 27705772 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14164267 times.
41870039 if(action!=climbcovertop&&action!=climbcoverbottom)
8163 {
8164 14164267 climb_cover_x=-1000;
8165 14164267 climb_cover_y=-1000;
8166 14164267 }
8167
8168 41870039 handle_portal_collide(&mirror_portal);
8169
1/2
✓ Branch 0 taken 41870039 times.
✗ Branch 1 not taken.
41870039 portals.forEach([&](sprite& p)
8170 {
8171 return handle_portal_collide((portal*)&p);
8172 });
8173
8174
3/4
✓ Branch 0 taken 14147812 times.
✓ Branch 1 taken 27722227 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14147812 times.
41870039 if(z<=8&&fakez<=8) //Tall Grass
8175 {
8176 14147812 int maxlyr = get_qr(qr_BUSHESONLAYERS1AND2) ? 2 : 0;
8177
2/2
✓ Branch 0 taken 632883 times.
✓ Branch 1 taken 13514929 times.
14147812 if (get_qr(qr_GRASS_SENSITIVE))
8178 {
8179 632883 bool g1 = false, g2 = false, g3 = false, g4 = false;
8180
2/2
✓ Branch 0 taken 1815587 times.
✓ Branch 1 taken 632883 times.
2448470 for(int q = maxlyr; q >= 0; --q)
8181 {
8182
2/2
✓ Branch 0 taken 2282 times.
✓ Branch 1 taken 1813305 times.
1815587 g1 = g1 || isGrassType(combobuf[MAPCOMBO2(q-1,x+4,y+15)].type);
8183
2/2
✓ Branch 0 taken 2251 times.
✓ Branch 1 taken 1813336 times.
1815587 g2 = g2 || isGrassType(combobuf[MAPCOMBO2(q-1,x+11,y+15)].type);
8184
2/2
✓ Branch 0 taken 2323 times.
✓ Branch 1 taken 1813264 times.
1815587 g3 = g3 || isGrassType(combobuf[MAPCOMBO2(q-1,x+4,y+9)].type);
8185
2/2
✓ Branch 0 taken 2350 times.
✓ Branch 1 taken 1813237 times.
1815587 g4 = g4 || isGrassType(combobuf[MAPCOMBO2(q-1,x+11,y+9)].type);
8186 1815587 }
8187
8/8
✓ Branch 0 taken 8260 times.
✓ Branch 1 taken 624623 times.
✓ Branch 2 taken 7135 times.
✓ Branch 3 taken 1125 times.
✓ Branch 4 taken 6227 times.
✓ Branch 5 taken 908 times.
✓ Branch 6 taken 62 times.
✓ Branch 7 taken 6165 times.
632883 if(g1 && g2 && g3 && g4)
8188 {
8189 6165 int grasscid = 0;
8190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16508 times.
16508 for(int q = maxlyr; q >= 0; --q)
8191 {
8192 16508 int cid = MAPCOMBO2(q-1,x+8,y+12);
8193
4/4
✓ Branch 0 taken 7637 times.
✓ Branch 1 taken 8871 times.
✓ Branch 2 taken 1472 times.
✓ Branch 3 taken 6165 times.
16508 if(cid > 0 && isGrassType(combobuf[cid].type))
8194 {
8195 6165 grasscid = cid;
8196 6165 break;
8197 }
8198 10343 }
8199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6165 times.
6165 if(grasscid)
8200 {
8201 6165 newcombo const& cmb = combobuf[grasscid];
8202
2/2
✓ Branch 0 taken 5003 times.
✓ Branch 1 taken 1162 times.
6165 if(decorations.idCount(dTALLGRASS)==0)
8203 {
8204
3/6
✓ Branch 0 taken 1162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
1162 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0, cmb.attribytes[6]));
8205 1162 }
8206 6165 int32_t thesfx = cmb.attribytes[3];
8207
2/2
✓ Branch 0 taken 2035 times.
✓ Branch 1 taken 4130 times.
6165 if (action==walking)
8208 4130 sfx_no_repeat(thesfx,pan((int32_t)x));
8209 6165 }
8210 6165 }
8211 632883 }
8212 else
8213 {
8214 13514929 bool g1 = false, g2 = false;
8215
2/2
✓ Branch 0 taken 13817865 times.
✓ Branch 1 taken 13514929 times.
27332794 for(int q = maxlyr; q >= 0; --q)
8216 {
8217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13817865 times.
13817865 g1 = g1 || isGrassType(combobuf[MAPCOMBO2(q-1,x,y+15)].type);
8218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13817865 times.
13817865 g2 = g2 || isGrassType(combobuf[MAPCOMBO2(q-1,x+15,y+15)].type);
8219 13817865 }
8220
4/4
✓ Branch 0 taken 135558 times.
✓ Branch 1 taken 13379371 times.
✓ Branch 2 taken 30116 times.
✓ Branch 3 taken 105442 times.
13514929 if(g1 && g2)
8221 {
8222 105442 int grasscid = 0;
8223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108736 times.
108736 for(int q = maxlyr; q >= 0; --q)
8224 {
8225 108736 int cid = MAPCOMBO2(q-1,x+8,y+15);
8226
3/4
✓ Branch 0 taken 105442 times.
✓ Branch 1 taken 3294 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105442 times.
108736 if(cid > 0 && isGrassType(combobuf[cid].type))
8227 {
8228 105442 grasscid = cid;
8229 105442 break;
8230 }
8231 3294 }
8232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105442 times.
105442 if(grasscid)
8233 {
8234 105442 newcombo const& cmb = combobuf[grasscid];
8235
2/2
✓ Branch 0 taken 102833 times.
✓ Branch 1 taken 2609 times.
105442 if(decorations.idCount(dTALLGRASS)==0)
8236 {
8237
3/6
✓ Branch 0 taken 2609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2609 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2609 times.
✗ Branch 5 not taken.
2609 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0, cmb.attribytes[6]));
8238 2609 }
8239 105442 int32_t thesfx = cmb.attribytes[3];
8240
2/2
✓ Branch 0 taken 38255 times.
✓ Branch 1 taken 67187 times.
105442 if (action==walking )
8241 67187 sfx_no_repeat(thesfx,pan((int32_t)x));
8242 105442 }
8243 105442 }
8244 }
8245 14147812 }
8246
3/4
✓ Branch 0 taken 14145611 times.
✓ Branch 1 taken 27724428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14145611 times.
41870039 if(z==0 && fakez==0) //Shallow Water / Custom Walk SFX
8247 {
8248
2/2
✓ Branch 0 taken 1126538 times.
✓ Branch 1 taken 13019073 times.
14145611 if (get_qr(qr_SHALLOW_SENSITIVE))
8249 {
8250
18/22
✓ Branch 0 taken 1118483 times.
✓ Branch 1 taken 8055 times.
✓ Branch 2 taken 1118483 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1114227 times.
✓ Branch 5 taken 4256 times.
✓ Branch 6 taken 1113971 times.
✓ Branch 7 taken 256 times.
✓ Branch 8 taken 1113971 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1113971 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1110191 times.
✓ Branch 13 taken 3780 times.
✓ Branch 14 taken 1110191 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1110158 times.
✓ Branch 17 taken 33 times.
✓ Branch 18 taken 1099747 times.
✓ Branch 19 taken 10411 times.
✓ Branch 20 taken 1288 times.
✓ Branch 21 taken 1098459 times.
1126538 if (action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
8251 {
8252
2/2
✓ Branch 0 taken 1045651 times.
✓ Branch 1 taken 52808 times.
1159014 if (iswaterex(FFORCOMBO(x+11,y+15), currmap, currscr, -1, x+11,y+15, false, false, true, true)
8253
2/2
✓ Branch 0 taken 60555 times.
✓ Branch 1 taken 1037904 times.
1098459 && iswaterex(FFORCOMBO(x+4,y+15), currmap, currscr, -1, x+4,y+15, false, false, true, true)
8254
2/2
✓ Branch 0 taken 56317 times.
✓ Branch 1 taken 4238 times.
60555 && iswaterex(FFORCOMBO(x+11,y+9), currmap, currscr, -1, x+11,y+9, false, false, true, true)
8255
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 52954 times.
56317 && iswaterex(FFORCOMBO(x+4,y+9), currmap, currscr, -1, x+4,y+9, false, false, true, true))
8256 {
8257 52808 int watercheck_x = x.getInt()+7.5, watercheck_y = y.getInt()+12;
8258 52808 int ffpos = getFFCAt(watercheck_x,watercheck_y);
8259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52808 times.
52808 int combopos = ffpos < 0 ? COMBOPOS(watercheck_x,watercheck_y) : -1;
8260
4/8
✓ Branch 0 taken 52808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52808 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52808 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 52808 times.
52808 if(watercheck_x < 0 || watercheck_x > 255 || watercheck_y < 0 || watercheck_y > 175)
8261 combopos = -1;
8262
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52808 times.
✓ Branch 2 taken 52808 times.
✗ Branch 3 not taken.
52808 int waterid = ffpos > -1 ? tmpscr->ffcs[ffpos].data : (combopos > -1 ? tmpscr->data[combopos] : 0);
8263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52808 times.
52808 if(waterid)
8264 52808 waterid = iswaterex(waterid, currmap, currscr, -1, watercheck_x,watercheck_y, false, false, true, true);
8265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52808 times.
52808 if(waterid)
8266 {
8267 52808 newcombo const& watercmb = combobuf[waterid];
8268 52808 auto ripplesprite = watercmb.attribytes[6];
8269
2/2
✓ Branch 0 taken 52361 times.
✓ Branch 1 taken 447 times.
52808 if(decorations.idCount(dRIPPLES)==0)
8270
3/6
✓ Branch 0 taken 447 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 447 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 447 times.
✗ Branch 5 not taken.
447 decorations.add(new dRipples(x, y, dRIPPLES, 0, ripplesprite));
8271
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 52185 times.
52808 if (watercmb.usrflags&cflag2)
8272 {
8273
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
623 if (!(current_item(watercmb.attribytes[2]) > 0 && current_item(watercmb.attribytes[2]) >= watercmb.attribytes[3]))
8274 {
8275 623 onpassivedmg = true;
8276
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 314 times.
623 if (!damageovertimeclk)
8277 {
8278 314 int32_t curhp = game->get_life();
8279 314 auto dmg = watercmb.attributes[1]/10000L;
8280 314 auto hitsfx = watercmb.attributes[2]/10000L;
8281
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 bool hitstun = dmg < 0 && (watercmb.usrflags&cflag7);
8282
8283
2/4
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 314 times.
314 if(game->get_life() == curhp && (watercmb.usrflags&cflag6))
8284 314 hitsfx = 0;
8285
8286 314 std::vector<int32_t> &ev = FFCore.eventData;
8287 314 ev.clear();
8288 314 ev.push_back(-dmg*10000);
8289 314 ev.push_back(-1*10000);
8290 314 ev.push_back(0);
8291 314 ev.push_back(0);
8292 314 ev.push_back(48*10000);
8293 314 ev.push_back(ZSD_COMBODATA*10000);
8294 314 ev.push_back(waterid);
8295 314 ev.push_back((ffpos > -1 ? ZSD_FFC : ZSD_COMBOPOS)*10000);
8296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 314 times.
314 ev.push_back(ffpos > -1 ? ffpos : combopos*10000);
8297
8298 314 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
8299
8300
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(watercmb.usrflags & cflag5)
8301 ev[0] = ringpower(ev[0]/10000) * 10000;
8302
8303 314 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
8304 314 dmg = -ev[0]/10000;
8305
8306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 314 times.
314 if(!ev[2]) //nullify
8307 {
8308 314 game->set_life(vbound(game->get_life()+dmg, 0, game->get_maxlife()));
8309
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if (hitsfx)
8310 sfx(hitsfx);
8311
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if (hitstun)
8312 {
8313 hclk = ev[4]/10000;
8314 hitdir = ev[1]/10000;
8315 action = gothit; FFCore.setHeroAction(gothit);
8316 }
8317 314 }
8318 314 }
8319
1/2
✓ Branch 0 taken 623 times.
✗ Branch 1 not taken.
623 if (watercmb.attribytes[1] > 0)
8320 {
8321
3/4
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 314 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 309 times.
623 if (!damageovertimeclk || damageovertimeclk > watercmb.attribytes[1]) damageovertimeclk = watercmb.attribytes[1];
8322 309 else --damageovertimeclk;
8323 623 }
8324 else damageovertimeclk = 0;
8325 623 }
8326 else damageovertimeclk = 0;
8327 623 }
8328 52185 else damageovertimeclk = 0;
8329 52808 int32_t thesfx = watercmb.attribytes[0];
8330
4/4
✓ Branch 0 taken 51858 times.
✓ Branch 1 taken 950 times.
✓ Branch 2 taken 46233 times.
✓ Branch 3 taken 5625 times.
52808 if (watercmb.type != cSHALLOWWATER || !get_qr(qr_OLD_SHALLOW_SFX))
8331 {
8332 6575 thesfx = watercmb.attribytes[5];
8333 6575 }
8334
2/2
✓ Branch 0 taken 28715 times.
✓ Branch 1 taken 24093 times.
52808 if (action==walking)
8335 24093 sfx_no_repeat(thesfx,pan((int32_t)x));
8336 52808 }
8337 52808 }
8338 1098459 }
8339 1126538 }
8340 else
8341 {
8342
4/4
✓ Branch 0 taken 12864153 times.
✓ Branch 1 taken 154920 times.
✓ Branch 2 taken 12877281 times.
✓ Branch 3 taken 141792 times.
13019073 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER))
8343 {
8344 141792 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
8345 141792 auto ripplesprite = combobuf[watercheck].attribytes[6];
8346
2/2
✓ Branch 0 taken 140401 times.
✓ Branch 1 taken 1391 times.
141792 if(decorations.idCount(dRIPPLES)==0)
8347 {
8348
3/6
✓ Branch 0 taken 1391 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1391 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1391 times.
✗ Branch 5 not taken.
1391 decorations.add(new dRipples(x, y, dRIPPLES, 0, ripplesprite));
8349 1391 }
8350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141792 times.
141792 if (combobuf[watercheck].usrflags&cflag2)
8351 {
8352 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
8353 {
8354 onpassivedmg = true;
8355 if (!damageovertimeclk)
8356 {
8357 int32_t curhp = game->get_life();
8358 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
8359 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
8360 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
8361 }
8362 if (combobuf[watercheck].attribytes[1] > 0)
8363 {
8364 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
8365 else --damageovertimeclk;
8366 }
8367 else damageovertimeclk = 0;
8368 }
8369 else damageovertimeclk = 0;
8370 }
8371 141792 else damageovertimeclk = 0;
8372 141792 int32_t thesfx = combobuf[watercheck].attribytes[0];
8373
2/2
✓ Branch 0 taken 53262 times.
✓ Branch 1 taken 88530 times.
141792 if (action==walking )
8374 88530 sfx_no_repeat(thesfx,pan((int32_t)x));
8375 141792 }
8376 }
8377
8378 14145611 auto cpos = COMBOPOS(x+8,y+(sideview_mode()?16:12));
8379
2/2
✓ Branch 0 taken 99019277 times.
✓ Branch 1 taken 14145611 times.
113164888 for(int q = 0; q < 7; ++q)
8380 {
8381 99019277 mapscr* lyr = FFCore.tempScreens[q];
8382 99019277 auto cid = lyr->data[cpos];
8383 99019277 newcombo const& cmb = combobuf[cid];
8384
2/2
✓ Branch 0 taken 52557918 times.
✓ Branch 1 taken 46461359 times.
99019277 byte csfx = action == walking ? cmb.sfx_walking : cmb.sfx_standing;
8385
2/2
✓ Branch 0 taken 52557918 times.
✓ Branch 1 taken 46461359 times.
99019277 byte cspr = action == walking ? cmb.spr_walking : cmb.spr_standing;
8386
2/2
✓ Branch 0 taken 9624 times.
✓ Branch 1 taken 99009653 times.
99019277 if(csfx)
8387 9624 sfx_no_repeat(csfx);
8388 99019277 auto indx = decorations.idFirst(dCUSTOMWALK);
8389
1/2
✓ Branch 0 taken 99019277 times.
✗ Branch 1 not taken.
99019277 if(cspr)
8390 {
8391 if(indx < 0)
8392 {
8393 if(decorations.add(new customWalkSprite(x, y, dCUSTOMWALK, 0, -1)))
8394 indx = decorations.Count()-1;
8395 }
8396 if(indx > -1)
8397 {
8398 if(customWalkSprite* spr = dynamic_cast<customWalkSprite*>(decorations.spr(indx)))
8399 spr->run_sprite(cspr);
8400 }
8401 }
8402 99019277 }
8403 14145611 }
8404
8405
2/2
✓ Branch 0 taken 41869618 times.
✓ Branch 1 taken 421 times.
41870039 if(stomping)
8406 421 stomping = false;
8407
8408
1/2
✓ Branch 0 taken 41870039 times.
✗ Branch 1 not taken.
41870039 if(getOnSideviewLadder())
8409 {
8410 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
8411 {
8412 setOnSideviewLadder(false);
8413 }
8414 else if(CANFORCEFACEUP)
8415 {
8416 setDir(up);
8417 }
8418 }
8419
8420
7/8
✓ Branch 0 taken 14147785 times.
✓ Branch 1 taken 27722254 times.
✓ Branch 2 taken 14141801 times.
✓ Branch 3 taken 5984 times.
✓ Branch 4 taken 14141545 times.
✓ Branch 5 taken 256 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 14141545 times.
41870039 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
8421 {
8422
2/2
✓ Branch 0 taken 13138095 times.
✓ Branch 1 taken 1003450 times.
14141545 if(!get_qr(qr_OLD_CHEST_COLLISION))
8423 {
8424 1003450 checkchest(cCHEST);
8425 1003450 checkchest(cLOCKEDCHEST);
8426 1003450 checkchest(cBOSSCHEST);
8427 1003450 }
8428
2/2
✓ Branch 0 taken 13574762 times.
✓ Branch 1 taken 566783 times.
14141545 if(!get_qr(qr_OLD_LOCKBLOCK_COLLISION))
8429 {
8430 566783 checkchest(cLOCKBLOCK);
8431 566783 checkchest(cBOSSLOCKBLOCK);
8432 566783 }
8433 14141545 }
8434 41870039 checksigns();
8435 41870039 checkgenpush();
8436
8437
4/4
✓ Branch 0 taken 13418673 times.
✓ Branch 1 taken 28451366 times.
✓ Branch 2 taken 2628 times.
✓ Branch 3 taken 13416045 times.
41870039 if(isStanding(true) && fall == 0)
8438 {
8439
1/2
✓ Branch 0 taken 13416045 times.
✗ Branch 1 not taken.
13416045 if(extra_jump_count > 0)
8440 extra_jump_count = 0;
8441 13416045 coyotetime = 0;
8442 13416045 }
8443
2/2
✓ Branch 0 taken 27721981 times.
✓ Branch 1 taken 732013 times.
28453994 else if(coyotetime < 65535)
8444 {
8445 732013 ++coyotetime;
8446 732013 }
8447
2/2
✓ Branch 0 taken 41861750 times.
✓ Branch 1 taken 8289 times.
41870039 if(can_use_item(itype_hoverboots,i_hoverboots))
8448 {
8449 8289 int32_t hoverid = current_item_id(itype_hoverboots);
8450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8289 times.
8289 if(!(itemsbuf[hoverid].flags & ITEM_FLAG1))
8451 {
8452
1/2
✓ Branch 0 taken 8289 times.
✗ Branch 1 not taken.
8289 if(hoverclk < 0) hoverclk = 0;
8453 8289 hoverflags &= ~HOV_OUT;
8454 8289 }
8455 8289 }
8456 41870039 bool platformfell2 = false;
8457 41870039 int32_t gravity3 = (zinit.gravity/100);
8458 41870039 int32_t termv = (zinit.terminalv);
8459 41870039 int32_t rocs = getRocsPressed();
8460
2/2
✓ Branch 0 taken 41863979 times.
✓ Branch 1 taken 6060 times.
41870039 if (rocs != -1)
8461 {
8462 6060 itemdata const& itm = itemsbuf[rocs];
8463
1/2
✓ Branch 0 taken 6060 times.
✗ Branch 1 not taken.
6060 if (itm.flags & ITEM_FLAG2)
8464 {
8465 if ((!(itm.flags & ITEM_FLAG3) || fall < 0) &&
8466 (!(itm.flags & ITEM_FLAG4) || fall > 0)) gravity3 = itm.misc3;
8467 }
8468
1/2
✓ Branch 0 taken 6060 times.
✗ Branch 1 not taken.
6060 if (itm.flags & ITEM_FLAG5)
8469 {
8470 termv = itm.misc4;
8471 if (fall > termv) fall = termv;
8472 }
8473 6060 }
8474
2/2
✓ Branch 0 taken 255625 times.
✓ Branch 1 taken 41614414 times.
41870039 if(sideview_mode()) // Sideview gravity
8475 {
8476 //Handle falling through a platform
8477 255625 bool platformfell = false;
8478
3/4
✓ Branch 0 taken 128755 times.
✓ Branch 1 taken 126870 times.
✓ Branch 2 taken 128755 times.
✗ Branch 3 not taken.
255625 if (on_sideview_solid_oldpos(this,true,3) && !on_sideview_solid_oldpos(this,false,3))
8479 {
8480 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
8481 y+=1; //Fall down a pixel instantly, through the platform.
8482 if(fall < 0) fall = 0;
8483 if(jumping < 0) jumping = 0;
8484 platformfell2 = true;
8485 }
8486 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
8487
2/2
✓ Branch 0 taken 250696 times.
✓ Branch 1 taken 4929 times.
255625 if(!get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON))
8488 {
8489
14/22
✓ Branch 0 taken 3996 times.
✓ Branch 1 taken 933 times.
✓ Branch 2 taken 933 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 933 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 933 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 933 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 921 times.
✓ Branch 12 taken 921 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 921 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 921 times.
✓ Branch 18 taken 921 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 4917 times.
✓ Branch 21 taken 12 times.
5862 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE)
8490
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 921 times.
✓ Branch 2 taken 921 times.
✗ Branch 3 not taken.
921 || ((y+(fall/100)<=0) &&
8491 // Extra checks if Smart Screen Scrolling is enabled
8492 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8493 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up)))))))
8494 {
8495 12 fall = jumping = 0; // Bumped his head
8496
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8497 y -= y.getInt()%8; //fix coords
8498 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8500 {
8501 12 checkdamagecombos(x+4, x+12, y-1, y-1);
8502 12 }
8503 12 }
8504 4929 }
8505 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
8506
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 255625 times.
✓ Branch 2 taken 255625 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 255625 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 255625 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 255625 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 255625 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 255625 times.
255625 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
8507 {
8508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255625 times.
255625 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
8509 //zprint2("ydif is: %d\n", ydiff);
8510 //zprint2("ydif is: %d\n", (int32_t)fall);
8511 255625 falling_oldy = y; // Stomp Boots-related variable
8512
5/8
✓ Branch 0 taken 48242 times.
✓ Branch 1 taken 207383 times.
✓ Branch 2 taken 48242 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48242 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 255625 times.
✗ Branch 7 not taken.
255625 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (((y.getInt()+ydiff+15)&0xF0)!=((y.getInt()+15)&0xF0)) && !platform_fallthrough())
8513 {
8514 ydiff -= (y.getInt()+ydiff)%16;
8515 }
8516
4/4
✓ Branch 0 taken 68669 times.
✓ Branch 1 taken 186956 times.
✓ Branch 2 taken 66794 times.
✓ Branch 3 taken 1875 times.
255625 if(ydiff && !get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8517 {
8518
2/2
✓ Branch 0 taken 1071 times.
✓ Branch 1 taken 804 times.
1875 if(ydiff > 0)
8519 {
8520
2/2
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 2196 times.
3222 for(auto q = 0; q < ydiff; ++q)
8521 {
8522
2/2
✓ Branch 0 taken 2151 times.
✓ Branch 1 taken 45 times.
2196 if(on_sideview_solid_oldpos(this, false, 0, 0, q))
8523 {
8524 45 ydiff = q;
8525 45 break;
8526 }
8527 2151 }
8528 1071 }
8529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 else if(ydiff < 0)
8530 {
8531
2/2
✓ Branch 0 taken 804 times.
✓ Branch 1 taken 1644 times.
2448 for(auto q = 0; q > ydiff; --q)
8532 {
8533
1/2
✓ Branch 0 taken 1644 times.
✗ Branch 1 not taken.
1644 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
8534
1/2
✓ Branch 0 taken 1644 times.
✗ Branch 1 not taken.
1644 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
8535 {
8536 ydiff = q;
8537 break;
8538 }
8539 1644 }
8540 804 }
8541 1875 }
8542 255625 y+=ydiff;
8543 255625 hs_starty+=ydiff;
8544
8545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255625 times.
255625 for(int32_t j=0; j<chainlinks.Count(); j++)
8546 {
8547 chainlinks.spr(j)->y+=ydiff;
8548 }
8549
8550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255625 times.
255625 if(Lwpns.idFirst(wHookshot)>-1)
8551 {
8552 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
8553 }
8554
8555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255625 times.
255625 if(Lwpns.idFirst(wHSHandle)>-1)
8556 {
8557 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
8558 }
8559 255625 }
8560 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
8561 {
8562 fall = hoverclk = jumping = 0;
8563 inair = false;
8564 hoverflags = 0;
8565 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
8566 {
8567 WalkflagInfo info;
8568 if (game->get_watergrav()<0)
8569 {
8570 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
8571 execute(info);
8572 }
8573 else
8574 {
8575 info = walkflag(x,y+15+2,2,down);
8576 execute(info);
8577 }
8578 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)-2), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false))) y+=(game->get_watergrav()/10000.0);
8579 }
8580 }
8581 // Stop hovering/falling if you land on something.
8582 255625 bool needFall = false;
8583
6/8
✓ Branch 0 taken 126382 times.
✓ Branch 1 taken 129243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 255625 times.
✓ Branch 4 taken 129243 times.
✓ Branch 5 taken 126382 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 129243 times.
255625 if((on_sideview_solid_oldpos(this) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
8584 {
8585 129243 stop_item_sfx(itype_hoverboots);
8586
2/2
✓ Branch 0 taken 126660 times.
✓ Branch 1 taken 2583 times.
129243 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8587 {
8588
4/6
✓ Branch 0 taken 126660 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124016 times.
✓ Branch 3 taken 2644 times.
✓ Branch 4 taken 124016 times.
✗ Branch 5 not taken.
126660 if(!getOnSideviewLadder() && (fall > 0 || get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON)))
8589 {
8590 126660 y.doFloor();
8591 126660 y-=(int32_t)y%8; //fix position
8592 126660 }
8593 126660 }
8594 else
8595 {
8596 2583 snap_platform();
8597 }
8598 129243 fall = hoverclk = jumping = 0;
8599 129243 inair = false;
8600 129243 hoverflags = 0;
8601
8602
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 129235 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
129243 if(y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) // Landed on the bottommost screen.
8603 8 y = 160;
8604 129243 }
8605 // Stop hovering if you press down.
8606
3/6
✓ Branch 0 taken 126382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126382 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126382 times.
✗ Branch 5 not taken.
126382 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
8607 {
8608 stop_item_sfx(itype_hoverboots);
8609 hoverclk = -hoverclk;
8610 reset_ladder();
8611 fall = gravity3;
8612 inair = false;
8613 }
8614
8/10
✓ Branch 0 taken 126382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2945 times.
✓ Branch 3 taken 123437 times.
✓ Branch 4 taken 1186 times.
✓ Branch 5 taken 1759 times.
✓ Branch 6 taken 1186 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 284 times.
✓ Branch 9 taken 902 times.
126382 else if (hoverclk < 1 && !inair && fall == 0 && !IsSideSwim() && justmoved <= 0)
8615 {
8616 902 needFall = true;
8617
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 174 times.
902 if (replay_version_check(0, 23))
8618 {
8619 728 zfix my = y + 4;
8620
2/2
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 1971 times.
2573 for (zfix ty = y + 1; ty < my; ++ty)
8621 {
8622
2/2
✓ Branch 0 taken 1845 times.
✓ Branch 1 taken 126 times.
1971 if (on_sideview_solid_oldpos(this, false, 0, 0, ty-y))
8623 {
8624 126 y = ty;
8625
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
8626 {
8627 if (!slopeid)
8628 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
8629 onplatid = 1;
8630 }
8631 126 needFall = false;
8632 126 break;
8633 }
8634 1845 }
8635 728 }
8636 else
8637 {
8638 174 zfix dy = 0;
8639 174 bool landed = false;
8640
3/6
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 174 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 174 times.
✗ Branch 5 not taken.
3132 dy = binary_search_zfix(0, 4, [&](zfix val, zfix& retval)
8641 {
8642
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 2784 times.
2958 if (on_sideview_solid_oldpos(this, false, 0, 0, val))
8643 {
8644 174 retval = val;
8645 174 landed = true;
8646 174 return BSEARCH_CONTINUE_TOWARD0;
8647 }
8648 2784 else return BSEARCH_CONTINUE_AWAY0;
8649 2958 });
8650
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 168 times.
174 if (dy)
8651 {
8652 168 push_move(0, dy);
8653 168 }
8654
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 168 times.
174 if (landed)
8655 {
8656
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 24 times.
168 if (check_new_slope(x, y + 0.0001_zf, 16, 16, old_x, old_y, false, true) < 0)
8657 {
8658
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 24 times.
144 if (!slopeid)
8659 24 slopeid = get_new_slope(x, y + 0.0001_zf, 16, 16, old_x, old_y).get_info().slope();
8660 144 onplatid = 1;
8661 144 }
8662 168 needFall = false;
8663 168 }
8664 }
8665 902 }
8666 125480 else needFall = true;
8667 // Continue falling.
8668
8669
4/4
✓ Branch 0 taken 248191 times.
✓ Branch 1 taken 7434 times.
✓ Branch 2 taken 129537 times.
✓ Branch 3 taken 118654 times.
255625 if(fall <= termv && needFall)
8670 {
8671 118654 inair = true;
8672
3/4
✓ Branch 0 taken 47095 times.
✓ Branch 1 taken 71559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47095 times.
118654 if(fall != 0 || hoverclk>0)
8673 71559 jumping++;
8674
8675 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8676
2/2
✓ Branch 0 taken 116656 times.
✓ Branch 1 taken 1998 times.
118654 if(get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON))
8677 {
8678
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116656 times.
✓ Branch 4 taken 116065 times.
✓ Branch 5 taken 591 times.
233312 if((_walkflag(x+4,y-(bigHitbox?9:1),0,SWITCHBLOCK_STATE)
8679
4/4
✓ Branch 0 taken 111190 times.
✓ Branch 1 taken 5466 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 110284 times.
116656 || (y<=(bigHitbox?9:1) &&
8680 // Extra checks if Smart Screen Scrolling is enabled
8681
2/6
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 906 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
906 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8682 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8683
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
5466 && fall < 0)
8684 {
8685 591 fall = jumping = 0; // Bumped his head
8686
8687 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8688
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 110 times.
591 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8689 {
8690 110 checkdamagecombos(x+4, x+12, y-1, y-1);
8691 110 }
8692 591 }
8693 116656 }
8694 else
8695 {
8696
10/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1998 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1998 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1998 times.
✓ Branch 6 taken 15 times.
✓ Branch 7 taken 1983 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1983 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1983 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1983 times.
✓ Branch 14 taken 1995 times.
✓ Branch 15 taken 3 times.
3996 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE)
8697
2/4
✓ Branch 0 taken 1983 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1983 times.
1983 || ((y<=0) &&
8698 // Extra checks if Smart Screen Scrolling is enabled
8699 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8700 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8701
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
15 && fall < 0)
8702 {
8703 3 fall = jumping = 0; // Bumped his head
8704 3 y -= y.getInt()%8; //fix coords
8705 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8707 {
8708 3 checkdamagecombos(x+4, x+12, y-1, y-1);
8709 3 }
8710 3 }
8711 }
8712
8713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118654 times.
118654 if(hoverclk > 0)
8714 {
8715 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8716 {
8717 --hoverclk;
8718 }
8719
8720 if(!hoverclk && !ladderx && !laddery)
8721 {
8722 fall += gravity3;
8723 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8724 }
8725 }
8726
5/12
✓ Branch 0 taken 85896 times.
✓ Branch 1 taken 32758 times.
✓ Branch 2 taken 47795 times.
✓ Branch 3 taken 38101 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47795 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
118654 else if(fall+gravity3 > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
8727 {
8728 int32_t itemid = current_item_id(itype_hoverboots);
8729 if(hoverclk < 0)
8730 hoverclk = -hoverclk;
8731 else
8732 {
8733 fall = jumping = 0;
8734 if(itemsbuf[itemid].misc1)
8735 hoverclk = itemsbuf[itemid].misc1;
8736 else
8737 {
8738 hoverclk = 1;
8739 hoverflags |= HOV_INF;
8740 }
8741
8742
8743 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8744 }
8745 if(itemsbuf[itemid].wpn)
8746 decorations.add(new dHover(x, y, dHOVER, 0));
8747 }
8748
4/8
✓ Branch 0 taken 118654 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118654 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 118654 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 118654 times.
118654 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8749 {
8750 118654 fall += gravity3;
8751
8752 118654 }
8753 118654 }
8754 255625 }
8755 else // Topdown gravity
8756 {
8757
4/4
✓ Branch 0 taken 27705774 times.
✓ Branch 1 taken 13908640 times.
✓ Branch 2 taken 13905182 times.
✓ Branch 3 taken 3458 times.
41614414 if (!(moveflags & FLAG_NO_FAKE_Z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8758
4/4
✓ Branch 0 taken 27705774 times.
✓ Branch 1 taken 13908640 times.
✓ Branch 2 taken 13905182 times.
✓ Branch 3 taken 3458 times.
41614414 if (!(moveflags & FLAG_NO_REAL_Z)) z-=fall/(spins && fall>0 ? 200:100);
8759
4/4
✓ Branch 0 taken 13890001 times.
✓ Branch 1 taken 27724413 times.
✓ Branch 2 taken 27743052 times.
✓ Branch 3 taken 41633053 times.
41614414 if(z>0||fakez>0)
8760 {
8761
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18639 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55467465 switch(action)
8762 {
8763 case swimming:
8764 {
8765 diveclk=0;
8766 action=walking; FFCore.setHeroAction(walking);
8767
8768 break;
8769 }
8770 case waterhold1:
8771 {
8772 action=landhold1; FFCore.setHeroAction(landhold1);
8773 break;
8774 }
8775
8776 case waterhold2:
8777 {
8778 action=landhold2; FFCore.setHeroAction(landhold2);
8779 break;
8780 }
8781
8782 default:
8783 18639 break;
8784 }
8785 18639 }
8786
8787
2/2
✓ Branch 0 taken 160107 times.
✓ Branch 1 taken 41651692 times.
41811799 for(int32_t j=0; j<chainlinks.Count(); j++)
8788 {
8789 160107 chainlinks.spr(j)->z=z;
8790 160107 chainlinks.spr(j)->fakez=fakez;
8791 160107 }
8792
8793
2/2
✓ Branch 0 taken 41606848 times.
✓ Branch 1 taken 44844 times.
41651692 if(Lwpns.idFirst(wHookshot)>-1)
8794 {
8795 44844 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8796 44844 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8797 44844 }
8798
8799
2/2
✓ Branch 0 taken 41604416 times.
✓ Branch 1 taken 47276 times.
41651692 if(Lwpns.idFirst(wHSHandle)>-1)
8800 {
8801 47276 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8802 47276 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8803 47276 }
8804
8805
3/4
✓ Branch 0 taken 13890001 times.
✓ Branch 1 taken 27761691 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13890001 times.
41651692 if(z<=0&&!(moveflags & FLAG_NO_REAL_Z))
8806 {
8807
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13890001 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13890001 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8808 {
8809
2/2
✓ Branch 0 taken 13889568 times.
✓ Branch 1 taken 433 times.
13890001 if(fall > 0)
8810 {
8811
7/8
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 423 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 411 times.
✓ Branch 7 taken 22 times.
433 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8812 22 sfx(WAV_ZN1SPLASH,x.getInt());
8813
8814 433 stomping = true;
8815 433 }
8816 13890001 }
8817 13890001 z = fall = 0;
8818
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13890001 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13890001 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8819 {
8820 13890001 jumping = 0;
8821
2/2
✓ Branch 0 taken 13885849 times.
✓ Branch 1 taken 4152 times.
13890001 if(check_pitslide(true) == -1)
8822 {
8823 13885849 hoverclk = 0;
8824 13885849 hoverflags = 0;
8825 13885849 }
8826
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 4135 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
4152 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8827 {
8828
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!--hoverclk)
8829 {
8830 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8831 }
8832 17 }
8833 13890001 }
8834 13890001 }
8835
3/4
✓ Branch 0 taken 13908640 times.
✓ Branch 1 taken 27743052 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13908640 times.
41651692 if(fakez<=0&&!(moveflags & FLAG_NO_FAKE_Z))
8836 {
8837
3/4
✓ Branch 0 taken 18639 times.
✓ Branch 1 taken 13890001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18639 times.
13908640 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8838 {
8839
1/2
✓ Branch 0 taken 13890001 times.
✗ Branch 1 not taken.
13890001 if(fakefall > 0)
8840 {
8841 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8842 sfx(WAV_ZN1SPLASH,x.getInt());
8843
8844 stomping = true;
8845 }
8846 13890001 }
8847 13908640 fakez = fakefall = 0;
8848
3/4
✓ Branch 0 taken 18639 times.
✓ Branch 1 taken 13890001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18639 times.
13908640 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8849 {
8850 13890001 jumping = 0;
8851
2/2
✓ Branch 0 taken 13885849 times.
✓ Branch 1 taken 4152 times.
13890001 if(check_pitslide(true) == -1)
8852 {
8853 13885849 hoverclk = 0;
8854 13885849 hoverflags = 0;
8855 13885849 }
8856
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 4135 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
4152 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8857 {
8858
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!--hoverclk)
8859 {
8860 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8861 }
8862 17 }
8863 13890001 }
8864 13908640 }
8865
8/10
✓ Branch 0 taken 13908558 times.
✓ Branch 1 taken 27743134 times.
✓ Branch 2 taken 13908558 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13871526 times.
✓ Branch 5 taken 37032 times.
✓ Branch 6 taken 13890083 times.
✓ Branch 7 taken 13890083 times.
✓ Branch 8 taken 13890083 times.
✗ Branch 9 not taken.
41651692 if(fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z>0 || fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)
8866 {
8867
4/6
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 15484 times.
✓ Branch 2 taken 3073 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3073 times.
27761609 if(fall != 0 || fakefall != 0 || hoverclk>0)
8868 15484 jumping++;
8869
8870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18557 times.
18557 if(hoverclk > 0)
8871 {
8872 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8873 {
8874 --hoverclk;
8875 }
8876
8877 if(!hoverclk)
8878 {
8879 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8880 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8881 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8882 }
8883 }
8884
9/16
✓ Branch 0 taken 10818 times.
✓ Branch 1 taken 7739 times.
✓ Branch 2 taken 3136 times.
✓ Branch 3 taken 7682 times.
✓ Branch 4 taken 3136 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15421 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15421 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15421 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 18557 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
18557 else if(((fall+(int32_t)(zinit.gravity / 100) > 0 && fall<=0 && !(moveflags & FLAG_NO_REAL_Z) && z > 0) || (fakefall+gravity3 > 0 && fakefall<=0 && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8885 {
8886 if(hoverclk < 0)
8887 hoverclk = -hoverclk;
8888 else
8889 {
8890 fall = 0;
8891 fakefall = 0;
8892 int32_t itemid = current_item_id(itype_hoverboots);
8893 if(itemsbuf[itemid].misc1)
8894 hoverclk = itemsbuf[itemid].misc1;
8895 else
8896 {
8897 hoverclk = 1;
8898 hoverflags |= HOV_INF;
8899 }
8900 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8901 }
8902 decorations.add(new dHover(x, y, dHOVER, 0));
8903 }
8904 else
8905 {
8906
3/6
✓ Branch 0 taken 18557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18557 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18557 times.
18557 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8907
3/6
✓ Branch 0 taken 18557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18557 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18557 times.
✗ Branch 5 not taken.
18557 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8908 }
8909 18557 }
8910
1/2
✓ Branch 0 taken 13908640 times.
✗ Branch 1 not taken.
13908640 if (fakez<0) fakez = 0;
8911
1/2
✓ Branch 0 taken 13908640 times.
✗ Branch 1 not taken.
13908640 if (z<0) z = 0;
8912 }
8913
8914
2/2
✓ Branch 0 taken 14163517 times.
✓ Branch 1 taken 748 times.
14164265 if(drunkclk)
8915 {
8916 748 --drunkclk;
8917 748 }
8918
8919
2/2
✓ Branch 0 taken 14163938 times.
✓ Branch 1 taken 327 times.
14164265 if(lstunclock > 0)
8920 {
8921 // also cancel Hero's attack
8922 327 attackclk = 0;
8923
8924
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 243 times.
327 if( FFCore.getHeroAction() != stunned )
8925 {
8926 243 tempaction=action; //update so future checks won't do this
8927 //action=freeze; //setting this makes the player invincible while stunned -V
8928 243 FFCore.setHeroAction(stunned);
8929 243 }
8930 327 --lstunclock;
8931 327 }
8932 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8933 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8934
4/4
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 14163938 times.
✓ Branch 2 taken 311 times.
✓ Branch 3 taken 16 times.
14164265 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8935 {
8936 16 action=tempaction; FFCore.setHeroAction(tempaction);
8937 //zprint("Unfreezing hero to action: %d\n", (int32_t)tempaction);
8938 //action=none; FFCore.setHeroAction(none);
8939 16 }
8940
8941
1/2
✓ Branch 0 taken 14164265 times.
✗ Branch 1 not taken.
14164265 if( lbunnyclock > 0 )
8942 {
8943 --lbunnyclock;
8944 }
8945
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 14162340 times.
14164265 if(DMaps[currdmap].flags&dmfBUNNYIFNOPEARL)
8946 {
8947 1925 int32_t itemid = current_item_id(itype_pearl);
8948
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 1802 times.
1925 if(itemid > -1)
8949 {
8950
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 1 times.
123 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8951 1 lbunnyclock = 0;
8952 123 }
8953
2/2
✓ Branch 0 taken 1801 times.
✓ Branch 1 taken 1 times.
1802 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8954 {
8955 1 lbunnyclock = -1;
8956 1 }
8957 1925 }
8958
1/2
✓ Branch 0 taken 14162340 times.
✗ Branch 1 not taken.
14162340 else if(lbunnyclock == -1) //dmap-caused bunny effect
8959 {
8960 lbunnyclock = 0;
8961 }
8962
8963
7/20
✗ Branch 0 not taken.
✓ Branch 1 taken 14164265 times.
✓ Branch 2 taken 14164265 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14164265 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14164265 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 14164265 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 14164265 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 14164265 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
28328530 bool is_broken_behavior = replay_is_active() && replay_get_meta_str("sav") == "link_to_the_zelda_2_of_3.sav";
8964
5/6
✓ Branch 0 taken 143268 times.
✓ Branch 1 taken 14020997 times.
✓ Branch 2 taken 18285 times.
✓ Branch 3 taken 124983 times.
✓ Branch 4 taken 14039282 times.
✗ Branch 5 not taken.
28203547 bool fall_check = (fall == 0 || z > 0) && (fakefall == 0 || fakez > 0);
8965
2/2
✓ Branch 0 taken 13847472 times.
✓ Branch 1 taken 316793 times.
14164265 if (is_broken_behavior)
8966
5/6
✓ Branch 0 taken 1196 times.
✓ Branch 1 taken 315597 times.
✓ Branch 2 taken 156 times.
✓ Branch 3 taken 1040 times.
✓ Branch 4 taken 1040 times.
✗ Branch 5 not taken.
316793 fall_check = (fall == 0 || z > 0) || (fakefall == 0 || fakez > 0);
8967
8968
12/14
✓ Branch 0 taken 14109542 times.
✓ Branch 1 taken 54723 times.
✓ Branch 2 taken 9703745 times.
✓ Branch 3 taken 4405797 times.
✓ Branch 4 taken 9703745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9703745 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9703735 times.
✓ Branch 9 taken 10 times.
✓ Branch 10 taken 9701926 times.
✓ Branch 11 taken 1809 times.
✓ Branch 12 taken 78687 times.
✓ Branch 13 taken 9622645 times.
14164265 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && fall_check && charging==0 && spins<=5
8969
2/2
✓ Branch 0 taken 9701332 times.
✓ Branch 1 taken 594 times.
9701926 && action != gothit)
8970 {
8971
2/3
✓ Branch 0 taken 4349591 times.
✓ Branch 1 taken 5273054 times.
✗ Branch 2 not taken.
9622645 switch(dir)
8972 {
8973 case up:
8974 case down:
8975 4349591 x=(x.getInt()+4)&0xFFF8;
8976 4349591 break;
8977
8978 case left:
8979 case right:
8980 5273054 y=(y.getInt()+4)&0xFFF8;
8981 5273054 break;
8982 }
8983 9622645 }
8984
8985
4/4
✓ Branch 0 taken 137817 times.
✓ Branch 1 taken 14026448 times.
✓ Branch 2 taken 85523 times.
✓ Branch 3 taken 52294 times.
14164265 if((watch==true) && clockclk)
8986 {
8987 52294 --clockclk;
8988
8989
2/2
✓ Branch 0 taken 52151 times.
✓ Branch 1 taken 143 times.
52294 if(!clockclk)
8990 {
8991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 if(cheat_superman==false)
8992 {
8993 143 setClock(false);
8994 143 }
8995
8996 143 watch=false;
8997
8998
2/2
✓ Branch 0 taken 73216 times.
✓ Branch 1 taken 143 times.
73359 for(int32_t i=0; i<eMAXGUYS; i++)
8999 {
9000
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 73216 times.
73223 for(int32_t zoras=0; zoras<clock_zoras[i]; zoras++)
9001 {
9002 7 addenemy(0,0,i,0);
9003 7 }
9004 73216 }
9005 143 }
9006 52294 }
9007
9008
4/4
✓ Branch 0 taken 14116989 times.
✓ Branch 1 taken 47276 times.
✓ Branch 2 taken 8704 times.
✓ Branch 3 taken 14108285 times.
14164265 if(hookshot_frozen || switch_hooked)
9009 {
9010
4/4
✓ Branch 0 taken 11136 times.
✓ Branch 1 taken 44844 times.
✓ Branch 2 taken 8704 times.
✓ Branch 3 taken 2432 times.
55980 if(hookshot_used || switch_hooked)
9011 {
9012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53548 times.
53548 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
9013 53548 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
9014
9015
3/4
✓ Branch 0 taken 36199 times.
✓ Branch 1 taken 17349 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36199 times.
53548 if(pull_hero || switch_hooked)
9016 {
9017
3/4
✓ Branch 0 taken 8585 times.
✓ Branch 1 taken 8764 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8585 times.
17349 if(hs_switcher || switch_hooked)
9018 {
9019 8764 hs_fix = false;
9020
1/2
✓ Branch 0 taken 8764 times.
✗ Branch 1 not taken.
8764 if(switchhookclk)
9021 {
9022 8764 --switchhookclk;
9023
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 8627 times.
8764 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
9024 {
9025
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 137 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
137 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
9026 reset_hookshot();
9027 else
9028 {
9029 137 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
9030 137 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
9031
9032
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 5 times.
137 if(hooked_combopos > -1) //Switching combos
9033 {
9034 132 uint16_t targpos = hooked_combopos, plpos = COMBOPOS(x+8,y+8);
9035
3/6
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
132 if(targpos < 176 && plpos < 176 && hooked_layerbits)
9036 {
9037
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
9038
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 132 times.
1056 for(int q = max_layer; q > -1; --q)
9039 {
9040
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 132 times.
924 if(!(hooked_layerbits & (1<<q)))
9041 792 continue; //non-switching layer
9042 132 mapscr* scr = FFCore.tempScreens[q];
9043 132 newcombo const& cmb = combobuf[scr->data[targpos]];
9044 132 int32_t srcfl = scr->sflag[targpos];
9045 132 newcombo const& comb2 = combobuf[scr->data[plpos]];
9046 132 int32_t c = scr->data[plpos], cs = scr->cset[plpos], fl = scr->sflag[plpos];
9047 //{Check push status
9048 132 bool isFakePush = false;
9049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(cmb.type == cSWITCHHOOK)
9050 {
9051
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag7) //counts as 'pushblock'
9052 isFakePush = true;
9053 132 }
9054 132 bool isPush = isFakePush;
9055
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(srcfl)
9056 {
9057 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
9058 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
9059 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
9060 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
9061 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
9062 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
9063 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
9064 isPush = true;
9065 132 }
9066
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(cmb.flag)
9067 {
9068 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
9069 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
9070 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
9071 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
9072 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
9073 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
9074 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
9075 isPush = true;
9076 132 }
9077
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(srcfl==mfPUSHED) isPush = false;
9078 //}
9079
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.type == cSWITCHHOOK) //custom flags and such
9080 {
9081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(cmb.usrflags&cflag3) //Breaks on swap
9082 {
9083 int32_t it = -1;
9084 int32_t thedropset = -1;
9085 if(cmb.usrflags&cflag4) //drop item
9086 {
9087 if(cmb.usrflags&cflag5)
9088 it = cmb.attribytes[2];
9089 else
9090 {
9091 it = select_dropitem(cmb.attribytes[2]);
9092 thedropset = cmb.attribytes[2];
9093 }
9094 }
9095
9096 breakable* br = new breakable(x, y, 0_zf,
9097 cmb, scr->cset[targpos], it, thedropset, cmb.attribytes[2],
9098 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
9099 br->switch_hooked = true;
9100 decorations.add(br);
9101 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
9102 hooked_undercombos[q] = -1;
9103
9104 if(cmb.usrflags&cflag6)
9105 {
9106 scr->data[targpos]++;
9107 }
9108 else
9109 {
9110 scr->data[targpos] = scr->undercombo;
9111 scr->cset[targpos] = scr->undercset;
9112 if(cmb.usrflags&cflag2)
9113 scr->sflag[targpos] = 0;
9114 }
9115 }
9116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 else if(isPush)
9117 {
9118 //Simulate a block clicking into place
9119 movingblock mtemp;
9120 mtemp.clear();
9121 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
9122 mtemp.dir = getPushDir(scr->sflag[targpos]);
9123 if(mtemp.dir < 0)
9124 mtemp.dir = getPushDir(cmb.flag);
9125 mtemp.clk = 1;
9126 mtemp.force_many = isFakePush;
9127 mtemp.no_icy = true;
9128 mtemp.animate(0);
9129 if((mtemp.bhole || mtemp.trigger)
9130 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
9131 || comb2.flag == mfBLOCKTRIGGER
9132 || comb2.flag == mfBLOCKHOLE))
9133 {
9134 scr->data[targpos] = scr->undercombo;
9135 scr->cset[targpos] = scr->undercset;
9136 scr->sflag[targpos] = 0;
9137 }
9138 else
9139 {
9140 scr->data[targpos] = c;
9141 scr->cset[targpos] = cs;
9142 if(cmb.usrflags&cflag2)
9143 scr->sflag[targpos] = fl;
9144 else
9145 scr->sflag[targpos] = 0;
9146 }
9147 }
9148 else
9149 {
9150 132 scr->data[plpos] = scr->data[targpos];
9151 132 scr->cset[plpos] = scr->cset[targpos];
9152
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag2)
9153 scr->sflag[plpos] = scr->sflag[targpos];
9154 132 scr->data[targpos] = c;
9155 132 scr->cset[targpos] = cs;
9156
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag2)
9157 scr->sflag[targpos] = fl;
9158 }
9159 132 }
9160 else if(isCuttableType(cmb.type)) //Break and drop effects
9161 {
9162 int32_t breakcs = scr->cset[targpos];
9163 if(isCuttableNextType(cmb.type)) //next instead of undercmb
9164 {
9165 scr->data[targpos]++;
9166 }
9167 else
9168 {
9169 scr->data[targpos] = scr->undercombo;
9170 scr->cset[targpos] = scr->undercset;
9171 scr->sflag[targpos] = 0;
9172 }
9173
9174 int32_t it = -1;
9175 int32_t thedropset = -1;
9176 if(isCuttableItemType(cmb.type)) //Drop an item
9177 {
9178 if ( (cmb.usrflags&cflag2) )
9179 {
9180 if(cmb.usrflags&cflag11)
9181 it = cmb.attribytes[1];
9182 else
9183 {
9184 it = select_dropitem(cmb.attribytes[1]);
9185 thedropset = cmb.attribytes[1];
9186 }
9187 }
9188 else
9189 {
9190 it = select_dropitem(12);
9191 thedropset = 12;
9192 }
9193 }
9194
9195 byte breaksfx = 0;
9196 if(get_qr(qr_MORESOUNDS)) //SFX
9197 {
9198 if (cmb.usrflags&cflag3)
9199 {
9200 breaksfx = cmb.attribytes[2];
9201 }
9202 else if(isBushType(cmb.type)
9203 || isFlowersType(cmb.type)
9204 || isGrassType(cmb.type))
9205 {
9206 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
9207 }
9208 }
9209
9210 //Clipping sprite
9211 int16_t decotype = (cmb.usrflags & cflag1) ?
9212 ((cmb.usrflags & cflag10)
9213 ? (cmb.attribytes[0])
9214 : (-1))
9215 : (0);
9216 if(decotype > 3) decotype = 0;
9217 if(!decotype)
9218 decotype = (isBushType(cmb.type) ? 1
9219 : (isFlowersType(cmb.type) ? 2
9220 : (isGrassType(cmb.type) ? 3
9221 : ((cmb.usrflags & cflag1) ? -1
9222 : -2))));
9223
9224 breakable* br = new breakable(x, y, 0_zf,
9225 cmb, breakcs, it, thedropset, breaksfx,
9226 decotype, cmb.attribytes[0], switchhookclk);
9227 br->switch_hooked = true;
9228 decorations.add(br);
9229 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
9230 hooked_undercombos[q] = -1;
9231 }
9232 else //Unknown type, just swap combos.
9233 {
9234 if(isPush)
9235 {
9236 //Simulate a block clicking into place
9237 movingblock mtemp;
9238 mtemp.clear();
9239 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
9240 mtemp.dir = getPushDir(scr->sflag[targpos]);
9241 if(mtemp.dir < 0)
9242 mtemp.dir = getPushDir(cmb.flag);
9243 mtemp.clk = 1;
9244 mtemp.animate(0);
9245 if(mtemp.bhole || mtemp.trigger)
9246 {
9247 scr->data[targpos] = scr->undercombo;
9248 scr->cset[targpos] = scr->undercset;
9249 scr->sflag[targpos] = 0;
9250 }
9251 else
9252 {
9253 scr->data[targpos] = c;
9254 scr->cset[targpos] = cs;
9255 scr->sflag[targpos] = 0;
9256 }
9257 }
9258 else
9259 {
9260 scr->data[plpos] = scr->data[targpos];
9261 scr->cset[plpos] = scr->cset[targpos];
9262 scr->data[targpos] = c;
9263 scr->cset[targpos] = cs;
9264 }
9265 }
9266 132 }
9267
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(switchhook_cost_item > -1)
9268 paymagiccost(switchhook_cost_item);
9269 132 zfix tx = x, ty = y;
9270 //Position the player at the combo
9271 132 x = COMBOX(targpos);
9272 132 y = COMBOY(targpos);
9273 132 dir = oppositeDir[dir];
9274
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
132 if(w && hw)
9275 {
9276 //Calculate chain shift
9277 zfix dx = (x-tx);
9278 zfix dy = (y-ty);
9279 if(w->dir < 4)
9280 {
9281 if(w->dir & 2)
9282 dx = 0;
9283 else dy = 0;
9284 }
9285 //Position the hook head at the handle
9286 w->x = hw->x + dx;
9287 w->y = hw->y + dy;
9288 w->dir = oppositeDir[w->dir];
9289 w->doAutoRotate(true);
9290 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
9291 w->flip ^= hflip;
9292 //Position the handle appropriately
9293 hw->x = x-(hw->x-tx);
9294 hw->y = y-(hw->y-ty);
9295 hw->dir = oppositeDir[hw->dir];
9296 hw->doAutoRotate(true);
9297 hw->flip ^= hflip;
9298 //Move chains
9299 for(int32_t j=0; j<chainlinks.Count(); j++)
9300 {
9301 chainlinks.spr(j)->x += dx;
9302 chainlinks.spr(j)->y += dy;
9303 }
9304 }
9305 132 hooked_combopos = plpos; //flip positions
9306 132 }
9307 else reset_hookshot();
9308 132 }
9309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if(switching_object) //Switching an object
9310 {
9311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(switchhook_cost_item > -1)
9312 paymagiccost(switchhook_cost_item);
9313 5 zfix tx = x, ty = y;
9314 //Position the player at the object
9315 5 x = switching_object->x;
9316 5 y = switching_object->y;
9317 5 dir = oppositeDir[dir];
9318 //Position the object at the player
9319 5 switching_object->x = tx;
9320 5 switching_object->y = ty;
9321
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
5 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
9322 2 switching_object->dir = oppositeDir[switching_object->dir];
9323 5 solid_update(false);
9324 5 switching_object->solid_update(false);
9325
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if(item* it = dynamic_cast<item*>(switching_object))
9326 {
9327 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
9328 {
9329 movefairynew2(it->x, it->y, *it);
9330 }
9331 }
9332
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
5 if(w && hw) //!TODO No fucking clue if diagonals work
9333 {
9334 //Calculate chain shift
9335 1 zfix dx = (x-tx);
9336 1 zfix dy = (y-ty);
9337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w->dir < 4)
9338 {
9339
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->dir & 2)
9340 1 dx = 0;
9341 else dy = 0;
9342 1 }
9343 //Position the hook head at the handle
9344 1 w->x = hw->x + dx;
9345 1 w->y = hw->y + dy;
9346 1 w->dir = oppositeDir[w->dir];
9347 1 w->doAutoRotate(true);
9348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
9349 1 w->flip ^= hflip;
9350 1 w->solid_update(false);
9351 //Position the handle appropriately
9352 1 hw->x = x-(hw->x-tx);
9353 1 hw->y = y-(hw->y-ty);
9354 1 hw->dir = oppositeDir[hw->dir];
9355 1 hw->doAutoRotate(true);
9356 1 hw->flip ^= hflip;
9357 1 hw->solid_update(false);
9358 //Move chains
9359
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
9360 {
9361 5 chainlinks.spr(j)->x += dx;
9362 5 chainlinks.spr(j)->y += dy;
9363 5 }
9364 1 }
9365 5 }
9366 }
9367 137 }
9368
2/2
✓ Branch 0 taken 8490 times.
✓ Branch 1 taken 137 times.
8627 else if(!switchhookclk)
9369 {
9370 137 reset_hookshot();
9371 137 }
9372 8764 }
9373 else reset_hookshot();
9374 8764 }
9375 else
9376 {
9377 sprite *t;
9378 int32_t i;
9379
9380
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8761 times.
✓ Branch 2 taken 176 times.
✓ Branch 3 taken 8585 times.
8761 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
9381 {
9382 /* do nothing */
9383 176 }
9384
9385 8585 t = Lwpns.spr(i);
9386
9387
2/2
✓ Branch 0 taken 17399 times.
✓ Branch 1 taken 8585 times.
25984 for(i=0; i<Lwpns.Count(); i++)
9388 {
9389 17399 sprite *s = Lwpns.spr(i);
9390
9391
2/2
✓ Branch 0 taken 8814 times.
✓ Branch 1 taken 8585 times.
17399 if(s->id==wHookshot)
9392 {
9393
2/2
✓ Branch 0 taken 2098 times.
✓ Branch 1 taken 6487 times.
8585 if (abs((s->y) - y) >= 1)
9394 {
9395
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 1219 times.
2098 if((s->y)>y)
9396 {
9397 879 y+=4;
9398
9399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 879 times.
879 if(Lwpns.idFirst(wHSHandle)!=-1)
9400 {
9401 879 t->y+=4;
9402 879 }
9403
9404 879 hs_starty+=4;
9405 879 }
9406
9407
2/2
✓ Branch 0 taken 1219 times.
✓ Branch 1 taken 879 times.
2098 if((s->y)<y)
9408 {
9409 1219 y-=4;
9410
9411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1219 times.
1219 if(Lwpns.idFirst(wHSHandle)!=-1)
9412 {
9413 1219 t->y-=4;
9414 1219 }
9415
9416 1219 hs_starty-=4;
9417 1219 }
9418 2098 }
9419 else
9420 {
9421 6487 y = (s->y);
9422 }
9423
2/2
✓ Branch 0 taken 6487 times.
✓ Branch 1 taken 2098 times.
8585 if (abs((s->x) - x) >= 1)
9424 {
9425
2/2
✓ Branch 0 taken 3335 times.
✓ Branch 1 taken 3152 times.
6487 if((s->x)>x)
9426 {
9427 3335 x+=4;
9428
9429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3335 times.
3335 if(Lwpns.idFirst(wHSHandle)!=-1)
9430 {
9431 3335 t->x+=4;
9432 3335 }
9433
9434 3335 hs_startx+=4;
9435 3335 }
9436
9437
2/2
✓ Branch 0 taken 3152 times.
✓ Branch 1 taken 3335 times.
6487 if((s->x)<x)
9438 {
9439 3152 x-=4;
9440
9441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3152 times.
3152 if(Lwpns.idFirst(wHSHandle)!=-1)
9442 {
9443 3152 t->x-=4;
9444 3152 }
9445
9446 3152 hs_startx-=4;
9447 3152 }
9448 6487 }
9449 else
9450 {
9451 2098 x = (s->x);
9452 }
9453 8585 }
9454 17399 }
9455 }
9456 17349 }
9457 53548 }
9458 else
9459 {
9460 2432 Lwpns.del(Lwpns.idFirst(wHSHandle));
9461 2432 reset_hookshot();
9462 }
9463
9464
1/2
✓ Branch 0 taken 55980 times.
✗ Branch 1 not taken.
55980 if(hs_fix)
9465 {
9466 if(dir==up)
9467 {
9468 y=int32_t(y+7)&0xF0;
9469 }
9470
9471 if(dir==down)
9472 {
9473 y=int32_t(y+7)&0xF0;
9474 }
9475
9476 if(dir==left)
9477 {
9478 x=int32_t(x+7)&0xF0;
9479 }
9480
9481 if(dir==right)
9482 {
9483 x=int32_t(x+7)&0xF0;
9484 }
9485
9486 hs_fix=false;
9487 }
9488
9489 55980 }
9490
9491
2/2
✓ Branch 0 taken 1262482 times.
✓ Branch 1 taken 12901783 times.
14164265 if(!get_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP))
9492 {
9493
2/2
✓ Branch 0 taken 5305 times.
✓ Branch 1 taken 12896478 times.
12901783 if(DrunkrLbtn())
9494 5305 selectNextBWpn(SEL_LEFT);
9495
2/2
✓ Branch 0 taken 12889003 times.
✓ Branch 1 taken 7475 times.
12896478 else if(DrunkrRbtn())
9496 7475 selectNextBWpn(SEL_RIGHT);
9497 12901783 }
9498
4/4
✓ Branch 0 taken 949920 times.
✓ Branch 1 taken 13214345 times.
✓ Branch 2 taken 939265 times.
✓ Branch 3 taken 10655 times.
14164265 if (get_qr(qr_SELECTAWPN) && get_qr(qr_USE_EX1_EX2_INVENTORYSWAP))
9499 {
9500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10655 times.
10655 if (rEx3btn())
9501 selectNextAWpn(SEL_LEFT);
9502
2/2
✓ Branch 0 taken 10654 times.
✓ Branch 1 taken 1 times.
10655 else if (rEx4btn())
9503 1 selectNextAWpn(SEL_RIGHT);
9504 10655 }
9505
9506
2/2
✓ Branch 0 taken 14163187 times.
✓ Branch 1 taken 1078 times.
14164265 if(rPbtn())
9507 {
9508
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1075 times.
1078 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
9509 1075 onViewMap();
9510 1078 }
9511
2/2
✓ Branch 0 taken 5016671 times.
✓ Branch 1 taken 14164265 times.
19180936 for(int32_t i=0; i<Lwpns.Count(); i++)
9512 {
9513 5016671 weapon *w = ((weapon*)Lwpns.spr(i));
9514
9515
6/6
✓ Branch 0 taken 4965768 times.
✓ Branch 1 taken 50903 times.
✓ Branch 2 taken 4503204 times.
✓ Branch 3 taken 462564 times.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 4503131 times.
5016671 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
9516 513540 addsparkle(i);
9517 5016671 }
9518
9519
2/2
✓ Branch 0 taken 14163030 times.
✓ Branch 1 taken 1235 times.
14164265 if(Lwpns.idCount(wPhantom))
9520 {
9521 1235 addsparkle2(pDIVINEFIREROCKET,pDIVINEFIREROCKETTRAIL);
9522 1235 addsparkle2(pDIVINEFIREROCKETRETURN,pDIVINEFIREROCKETTRAILRETURN);
9523 1235 addsparkle2(pDIVINEPROTECTIONROCKET1,pDIVINEPROTECTIONROCKETTRAIL1);
9524 1235 addsparkle2(pDIVINEPROTECTIONROCKET2,pDIVINEPROTECTIONROCKETTRAIL2);
9525 1235 addsparkle2(pDIVINEPROTECTIONROCKETRETURN1,pDIVINEPROTECTIONROCKETTRAILRETURN1);
9526 1235 addsparkle2(pDIVINEPROTECTIONROCKETRETURN2,pDIVINEPROTECTIONROCKETTRAILRETURN2);
9527 1235 }
9528
9529 // Pay magic cost for Byrna beams
9530
9531 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
9532
2/2
✓ Branch 0 taken 14164192 times.
✓ Branch 1 taken 73 times.
14164265 if(Lwpns.idCount(wCByrna))
9533 {
9534 73 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
9535 73 int32_t itemid = ew->parentitem;
9536
9537
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
73 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
9538 {
9539 for(int32_t i=0; i<Lwpns.Count(); i++)
9540 {
9541 weapon *w = ((weapon*)Lwpns.spr(i));
9542
9543 if(w->id==wCByrna)
9544 {
9545 w->dead=1;
9546 }
9547
9548 }
9549 //kill the sound effect for the orbits -Z 14FEB2019
9550 stop_sfx(itemsbuf[itemid].usesound);
9551 }
9552 73 else paymagiccost(itemid);
9553 73 }
9554
9555
3/4
✓ Branch 0 taken 14145626 times.
✓ Branch 1 taken 18639 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14145626 times.
14164265 if(z==0&&fakez==0)
9556 {
9557 14145626 switchblock_z = 0;
9558
1/2
✓ Branch 0 taken 14145626 times.
✗ Branch 1 not taken.
14145626 if(switchblock_offset)
9559 {
9560 switchblock_offset=false;
9561 yofs += 8;
9562 }
9563 14145626 }
9564
2/2
✓ Branch 0 taken 255625 times.
✓ Branch 1 taken 13908640 times.
14164265 if(!isSideViewHero())
9565 {
9566 13908640 int32_t tx = x.getInt()+8,
9567 13908640 ty = y.getInt()+8;//(bigHitbox?8:12);
9568
4/4
✓ Branch 0 taken 13908204 times.
✓ Branch 1 taken 436 times.
✓ Branch 2 taken 368 times.
✓ Branch 3 taken 13907836 times.
13908640 if(!(unsigned(ty)>175 || unsigned(tx) > 255))
9569 {
9570
2/2
✓ Branch 0 taken 13907836 times.
✓ Branch 1 taken 41723508 times.
55631344 for(int32_t q = 0; q < 3; ++q)
9571 {
9572
4/4
✓ Branch 0 taken 27815672 times.
✓ Branch 1 taken 13907836 times.
✓ Branch 2 taken 7744794 times.
✓ Branch 3 taken 20070878 times.
41723508 if(q && !tmpscr2[q-1].valid) continue;
9573 21652630 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[COMBOPOS(tx,ty)]];
9574
3/4
✓ Branch 0 taken 4519 times.
✓ Branch 1 taken 21648111 times.
✓ Branch 2 taken 4519 times.
✗ Branch 3 not taken.
21652630 if(cmb.type != cCSWITCHBLOCK || !(cmb.usrflags&cflag9)) continue;
9575 int32_t b = 1;
9576 if(tx&8) b <<= 2;
9577 if(ty&8) b <<= 1;
9578 b |= (b<<4); //check equivalent effect flag too
9579 if((cmb.walk&b)==b) //solid and effecting
9580 {
9581 if(z==0&&fakez==0)
9582 {
9583 if(cmb.usrflags&cflag10)
9584 {
9585 if(!switchblock_offset)
9586 {
9587 switchblock_offset=true;
9588 yofs -= 8;
9589 }
9590 }
9591 else
9592 {
9593 if(switchblock_offset)
9594 {
9595 switchblock_offset=false;
9596 yofs += 8;
9597 }
9598 }
9599 }
9600 if(cmb.attributes[2]>0 && switchblock_z>=0)
9601 {
9602 if(z==0&&fakez==0)
9603 switchblock_z = zc_max(switchblock_z,zslongToFix(cmb.attributes[2]));
9604 else if(SWITCHBLOCK_STATE < zslongToFix(cmb.attributes[2]))
9605 {
9606 switchblock_z += zslongToFix(cmb.attributes[2])-SWITCHBLOCK_STATE;
9607 }
9608 }
9609 else switchblock_z = -1;
9610 break;
9611 }
9612 }
9613 13907836 }
9614 13908640 }
9615 14164265 ClearhitHeroUIDs(); //clear them before we advance.
9616 14164265 checkhit();
9617
9618 14164265 bool forcedeath = dying_flags&DYING_FORCED;
9619 14164265 bool norev = (dying_flags&DYING_NOREV);
9620
4/6
✓ Branch 0 taken 14164265 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 556 times.
✓ Branch 3 taken 14163709 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 556 times.
14164265 if(forcedeath || (game->get_life()<=0 && !immortal))
9621 {
9622
1/2
✓ Branch 0 taken 556 times.
✗ Branch 1 not taken.
556 if(forcedeath)
9623 game->set_life(0);
9624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!norev)
9625
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 142336 times.
142892 for(size_t slot = 0; slot < 256; ++slot)
9626 {
9627
2/2
✓ Branch 0 taken 142328 times.
✓ Branch 1 taken 8 times.
142336 if(size_t bind = game->get_bottle_slot(slot))
9628 {
9629 8 bottletype const* bt = &QMisc.bottle_types[bind-1];
9630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!(bt->flags&BTFLAG_AUTOONDEATH))
9631 8 continue;
9632 word toFill[3] = { 0 };
9633 for(size_t q = 0; q < 3; ++q)
9634 {
9635 char c = bt->counter[q];
9636 if(c > -1)
9637 {
9638 if(bt->flags & (1<<q))
9639 {
9640 toFill[q] = (bt->amount[q]==100)
9641 ? game->get_maxcounter(c)
9642 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
9643 }
9644 else toFill[q] = bt->amount[q];
9645 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
9646 {
9647 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
9648 }
9649 }
9650 }
9651 if(bt->flags & BTFLAG_CURESWJINX)
9652 {
9653 swordclk = 0;
9654 verifyAWpn();
9655 }
9656 if(bt->flags & BTFLAG_CUREITJINX)
9657 itemclk = 0;
9658 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
9659 {
9660 int32_t itemid = find_bottle_for_slot(slot,true);
9661 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
9662 if(itemid > -1)
9663 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
9664 for(size_t q = 0; q < 20; ++q)
9665 do_death_refill_waitframe();
9666 double inc = max/60.0; //1 second
9667 double xtra[3]{ 0 };
9668 for(size_t q = 0; q < 60; ++q)
9669 {
9670 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
9671 sfx(QMisc.miscsfx[sfxREFILL]);
9672 for(size_t j = 0; j < 3; ++j)
9673 {
9674 xtra[j] += inc;
9675 word f = floor(xtra[j]);
9676 xtra[j] -= f;
9677 if(toFill[j] > f)
9678 {
9679 toFill[j] -= f;
9680 game->change_counter(f,bt->counter[j]);
9681 }
9682 else if(toFill[j])
9683 {
9684 game->change_counter(toFill[j],bt->counter[j]);
9685 toFill[j] = 0;
9686 }
9687 }
9688 do_death_refill_waitframe();
9689 }
9690 for(size_t j = 0; j < 3; ++j)
9691 {
9692 if(toFill[j])
9693 {
9694 game->change_counter(toFill[j],bt->counter[j]);
9695 toFill[j] = 0;
9696 }
9697 }
9698 for(size_t q = 0; q < 20; ++q)
9699 do_death_refill_waitframe();
9700 }
9701 game->set_bottle_slot(slot,bt->next_type);
9702 if(game->get_life() > 0)
9703 {
9704 dying_flags = 0;
9705 forcedeath = false;
9706 break; //Revived! Stop drinking things...
9707 }
9708 }
9709 142884 }
9710
9711
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 496 times.
556 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9712 {
9713
3/6
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
60 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9714 {
9715 // So scripts can have one frame to handle hp zero events
9716
3/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 35 times.
60 if(norev || false == (last_hurrah = !last_hurrah))
9717 {
9718 25 dying_flags = 0;
9719 25 drunkclk=0;
9720 25 lstunclock = 0;
9721 25 is_conveyor_stunned = 0;
9722 25 FFCore.setHeroAction(dying);
9723 25 FFCore.deallocateAllScriptOwned(ScriptType::Global, GLOBAL_SCRIPT_GAME);
9724 25 FFCore.deallocateAllScriptOwned(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
9725 25 ALLOFF(true,true);
9726 25 GameFlags |= GAMEFLAG_NO_F6;
9727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!debug_enabled)
9728 {
9729 25 Paused=false;
9730 25 }
9731
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 10 times.
25 if(!get_qr(qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9732 {
9733 10 FFCore.runOnDeathEngine();
9734 10 FFCore.deallocateAllScriptOwned(ScriptType::Player, SCRIPT_PLAYER_DEATH);
9735 10 }
9736 25 Playing = false;
9737 25 heroDeathAnimation();
9738
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 15 times.
25 if(get_qr(qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9739 {
9740 15 Playing = true;
9741 15 FFCore.runOnDeathEngine();
9742 15 FFCore.deallocateAllScriptOwned(ScriptType::Player, SCRIPT_PLAYER_DEATH);
9743 15 Playing = false;
9744 15 }
9745 25 GameFlags &= ~GAMEFLAG_NO_F6;
9746 25 ALLOFF(true,true);
9747 25 return true;
9748 }
9749 35 }
9750 35 }
9751 else //2.50.x
9752 {
9753 // So scripts can have one frame to handle hp zero events
9754
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 249 times.
496 if(false == (last_hurrah = !last_hurrah))
9755 {
9756 247 drunkclk=0;
9757 247 heroDeathAnimation();
9758
9759 247 return true;
9760 }
9761 }
9762 284 }
9763 14163709 else last_hurrah=false;
9764
9765
2/2
✓ Branch 0 taken 14115226 times.
✓ Branch 1 taken 48767 times.
14163993 if(swordclk>0)
9766 {
9767 48767 --swordclk;
9768
2/2
✓ Branch 0 taken 48430 times.
✓ Branch 1 taken 337 times.
48767 if(!swordclk) verifyAWpn();
9769 48767 }
9770
2/2
✓ Branch 0 taken 14154835 times.
✓ Branch 1 taken 9158 times.
14163993 if(itemclk>0)
9771 9158 --itemclk;
9772
1/2
✓ Branch 0 taken 14163993 times.
✗ Branch 1 not taken.
14163993 if(shieldjinxclk>0)
9773 --shieldjinxclk;
9774
9775
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 14162655 times.
14163993 if(inwallm)
9776 {
9777 1338 attackclk=0;
9778 1338 herostep();
9779
9780
2/2
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 9 times.
1338 if(CarryHero()==false)
9781 9 restart_level();
9782
9783 1338 solid_update(false);
9784 1338 return false;
9785 }
9786
9787
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 14162652 times.
14162655 if(ewind_restart)
9788 {
9789 3 attackclk=0;
9790 3 restart_level();
9791 3 xofs=0;
9792 3 action=none; FFCore.setHeroAction(none);
9793 3 ewind_restart=false;
9794 3 solid_update(false);
9795 3 return false;
9796 }
9797
9798
2/2
✓ Branch 0 taken 14081 times.
✓ Branch 1 taken 14148571 times.
14162652 if(hopclk)
9799 {
9800 14081 action=hopping; FFCore.setHeroAction(hopping);
9801 14081 }
9802
2/2
✓ Branch 0 taken 3780 times.
✓ Branch 1 taken 14158872 times.
14162652 if(fallclk)
9803 {
9804 3780 action=falling; FFCore.setHeroAction(falling);
9805 3780 }
9806
9807
5/6
✓ Branch 0 taken 136379 times.
✓ Branch 1 taken 14026273 times.
✓ Branch 2 taken 1633 times.
✓ Branch 3 taken 134746 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1633 times.
14162652 if(isSwimming() && (liftflags&LIFTFL_DIS_SWIMMING) && !get_qr(qr_BROKEN_LIFTSWIM))
9808 1633 drop_liftwpn();
9809 14162652 handle_passive_buttons();
9810
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 14161620 times.
14162652 if(liftclk)
9811 {
9812
1/2
✓ Branch 0 taken 1032 times.
✗ Branch 1 not taken.
1032 if(lift_wpn)
9813 {
9814 1032 action=lifting; FFCore.setHeroAction(lifting);
9815 1032 }
9816 else
9817 {
9818 liftclk = 0;
9819 tliftclk = 0;
9820 }
9821 1032 }
9822
2/2
✓ Branch 0 taken 14151603 times.
✓ Branch 1 taken 10017 times.
14161620 else if(lift_wpn)
9823 {
9824 10017 handle_lift(false);
9825 10017 }
9826
9827
9828 // get user input or do other animation
9829 14162652 freeze_guys=false; // reset this flag, set it again if holding
9830
9831
14/16
✓ Branch 0 taken 14043718 times.
✓ Branch 1 taken 118934 times.
✓ Branch 2 taken 14017406 times.
✓ Branch 3 taken 26312 times.
✓ Branch 4 taken 14016234 times.
✓ Branch 5 taken 1172 times.
✓ Branch 6 taken 14015583 times.
✓ Branch 7 taken 651 times.
✓ Branch 8 taken 14015583 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 14015583 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 13992330 times.
✓ Branch 13 taken 23253 times.
✓ Branch 14 taken 13992214 times.
✓ Branch 15 taken 116 times.
14162652 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9832 {
9833 116 holdclk=0;
9834 116 }
9835
9836 14162652 active_shield_id = refreshActiveShield();
9837 14162652 bool sh = active_shield_id > -1;
9838 14162652 itemdata const& shield = itemsbuf[active_shield_id];
9839 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9840 14162652 shield_forcedir = -1;
9841
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14162652 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14162652 if(sh && action != rafting && (shield.flags & ITEM_FLAG11)) //Lock Dir
9842 {
9843 shield_forcedir = dir;
9844 }
9845
1/2
✓ Branch 0 taken 14162652 times.
✗ Branch 1 not taken.
14162652 if(sh != shield_active) //Toggle active shield on/off
9846 {
9847 shield_active = sh;
9848 if(sh) //Toggle active shield on
9849 {
9850 sfx(shield.usesound2); //'Activate' sfx
9851 }
9852 }
9853
9854 14162652 bool isthissolid = false;
9855
12/12
✓ Branch 0 taken 134909 times.
✓ Branch 1 taken 1823 times.
✓ Branch 2 taken 6144 times.
✓ Branch 3 taken 310942 times.
✓ Branch 4 taken 3887 times.
✓ Branch 5 taken 145246 times.
✓ Branch 6 taken 13421973 times.
✓ Branch 7 taken 102241 times.
✓ Branch 8 taken 3780 times.
✓ Branch 9 taken 14081 times.
✓ Branch 10 taken 16594 times.
✓ Branch 11 taken 1032 times.
14162652 switch(action)
9856 {
9857 case gothit:
9858
2/2
✓ Branch 0 taken 99948 times.
✓ Branch 1 taken 2293 times.
102241 if(attackclk)
9859
2/2
✓ Branch 0 taken 1986 times.
✓ Branch 1 taken 307 times.
2600 if(!doattack())
9860 {
9861 307 attackclk=spins=0;
9862 307 tapping=false;
9863 307 }
9864
9865 102241 break;
9866
9867 case drowning:
9868 case lavadrowning:
9869 case sidedrowning:
9870 {
9871 6144 herostep(); // maybe this line should be elsewhere?
9872
9873 //!DROWN
9874 // Helpful comment to find drowning -Dimi
9875
9876 6144 drop_liftwpn();
9877
2/2
✓ Branch 0 taken 6048 times.
✓ Branch 1 taken 96 times.
6144 if(--drownclk==0)
9878 {
9879 96 action=none; FFCore.setHeroAction(none);
9880
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 int32_t water = drownCombo ? drownCombo : iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9881
9882 96 std::vector<int32_t> &ev = FFCore.eventData;
9883 96 ev.clear();
9884 96 ev.push_back(water*10000);
9885
9886 96 throwGenScriptEvent(GENSCR_EVENT_PLAYER_DROWN);
9887 96 water = ev[0]/10000;
9888 96 newcombo const& watercmb = combobuf[water];
9889
9890 96 int32_t damage = 4;
9891
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 28 times.
96 if (watercmb.type == cWATER)
9892 68 damage = watercmb.attributes[0]/10000L;
9893 28 else water = 0;
9894
9895
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96 if(cheat_superman && damage > 0)
9896 damage = 0;
9897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(damage)
9898 96 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9899 96 drownCombo = 0;
9900 96 go_respawn_point();
9901 96 hclk=48;
9902 96 }
9903
9904 6144 break;
9905 }
9906 case falling:
9907 {
9908 3780 herostep();
9909 3780 pitfall();
9910 3780 break;
9911 }
9912 case freeze:
9913 case sideswimfreeze:
9914 case scrolling:
9915 310942 break;
9916
9917 case casting:
9918 case sideswimcasting:
9919 {
9920
2/2
✓ Branch 0 taken 3878 times.
✓ Branch 1 taken 9 times.
3887 if(magicitem==-1)
9921 {
9922 9 action=none; FFCore.setHeroAction(none);
9923 9 }
9924
9925 3887 break;
9926 }
9927 case landhold1:
9928 case landhold2:
9929 {
9930
2/2
✓ Branch 0 taken 1212 times.
✓ Branch 1 taken 144034 times.
145246 if(--holdclk <= 0)
9931 {
9932 //restart music
9933
4/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 1128 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 35 times.
1212 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9934 35 playLevelMusic();
9935
9936 1212 action=none; FFCore.setHeroAction(none);
9937 1212 post_item_collect();
9938 1212 }
9939 else
9940 144034 freeze_guys=true;
9941
9942 145246 break;
9943 }
9944 case waterhold1:
9945 case waterhold2:
9946 case sidewaterhold1:
9947 case sidewaterhold2:
9948 {
9949 1823 diveclk=0;
9950
9951
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1807 times.
1823 if(--holdclk <= 0)
9952 {
9953 //restart music
9954
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9955 playLevelMusic();
9956
9957 16 SetSwim();
9958 16 post_item_collect();
9959 16 }
9960 else
9961 1807 freeze_guys=true;
9962
9963 1823 break;
9964 }
9965 case hopping:
9966 {
9967
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 14068 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
14081 if(DRIEDLAKE)
9968 {
9969 action=none; FFCore.setHeroAction(none);
9970 hopclk = 0;
9971 diveclk = 0;
9972 break;
9973 }
9974
9975 14081 do_hopping();
9976 14081 break;
9977 }
9978 case inwind:
9979 {
9980 16594 int32_t i=Lwpns.idFirst(wWind);
9981
9982
2/2
✓ Branch 0 taken 16371 times.
✓ Branch 1 taken 223 times.
16594 if(i<0)
9983 {
9984 223 bool exit=false;
9985
9986
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 112 times.
223 if(whirlwind==255)
9987 {
9988 111 exit=true;
9989 111 }
9990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 else if(y<=0 && dir==up) y=-1;
9991
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 else if(y>=160 && dir==down) y=161;
9992
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 else if(x<=0 && dir==left) x=-1;
9993
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
112 else if(x>=240 && dir==right) x=241;
9994 else exit=true;
9995
9996
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 111 times.
223 if(exit)
9997 {
9998 111 action=none; FFCore.setHeroAction(none);
9999 111 xofs=0;
10000 111 whirlwind=0;
10001 111 lstep=0;
10002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if ( dontdraw < 2 ) dontdraw=0;
10003 111 set_respawn_point();
10004 111 }
10005 223 }
10006 /*
10007 else if (((weapon*)Lwpns.spr(i))->dead==1)
10008 {
10009 whirlwind=255;
10010 }
10011 */
10012 else
10013 {
10014 16371 x=Lwpns.spr(i)->x;
10015 16371 y=Lwpns.spr(i)->y;
10016 16371 dir=Lwpns.spr(i)->dir;
10017 }
10018 }
10019 16594 break;
10020 case lifting:
10021 1032 handle_lift();
10022 1032 break;
10023
10024 case sideswimming:
10025 case sideswimattacking:
10026 case sideswimhit:
10027 case swimhit:
10028 case swimming:
10029 {
10030
3/4
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 134743 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
134909 if(DRIEDLAKE)
10031 {
10032 action=none; FFCore.setHeroAction(none);
10033 hopclk=0;
10034 break;
10035 }
10036
10037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134909 times.
134909 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
10038
10039
4/4
✓ Branch 0 taken 67399 times.
✓ Branch 1 taken 67510 times.
✓ Branch 2 taken 626 times.
✓ Branch 3 taken 66773 times.
134909 if((frame&1) && !shouldbreak)
10040 66773 herostep();
10041
10042
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 134909 times.
✓ Branch 2 taken 134909 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10279 times.
✓ Branch 5 taken 124630 times.
145411 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
10043
4/6
✓ Branch 0 taken 124407 times.
✓ Branch 1 taken 10502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10502 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10502 times.
134909 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
10044
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 10493 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10493 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10493 times.
10502 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
10045
4/6
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 10279 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10279 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10279 times.
135123 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
10046
4/4
✓ Branch 0 taken 126779 times.
✓ Branch 1 taken 8130 times.
✓ Branch 2 taken 126779 times.
✓ Branch 3 taken 8130 times.
134909 if ((get_qr(qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
10047 {
10048
4/4
✓ Branch 0 taken 8082 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 8027 times.
✓ Branch 3 taken 4 times.
16161 if(!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+9), currmap, currscr, -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+15), currmap, currscr, -1, x.getInt()+4,y.getInt()+15, true, false)
10049
4/4
✓ Branch 0 taken 8058 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 8031 times.
✓ Branch 3 taken 27 times.
8082 || !iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+9), currmap, currscr, -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+15), currmap, currscr, -1, x.getInt()+11,y.getInt()+15, true, false))
10050 {
10051 103 hopclk=0;
10052 103 diveclk=0;
10053
2/4
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103 times.
103 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
10054 else {action=attacking; FFCore.setHeroAction(attacking);}
10055 103 hopdir=-1;
10056 103 }
10057 8130 }
10058
2/2
✓ Branch 0 taken 1259 times.
✓ Branch 1 taken 133650 times.
134909 if (shouldbreak) break;
10059
4/6
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 133547 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 103 times.
133650 if (action == swimming || action == sideswimming || action == sideswimattacking)
10060 {
10061 133547 int32_t watercheck = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
10062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133547 times.
133547 if (combobuf[watercheck].usrflags&cflag2)
10063 {
10064 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
10065 {
10066 onpassivedmg = true;
10067 if (damageovertimeclk == 0)
10068 {
10069 int32_t curhp = game->get_life();
10070 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
10071 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
10072 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
10073 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
10074 {
10075 hclk = 48;
10076 hitdir = -1;
10077 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
10078 else {action = swimhit; FFCore.setHeroAction(swimhit);}
10079 }
10080 }
10081 if (combobuf[watercheck].attribytes[1] > 0)
10082 {
10083 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
10084 else --damageovertimeclk;
10085 }
10086 else damageovertimeclk = 0;
10087 }
10088 else damageovertimeclk = 0;
10089 }
10090 133547 else damageovertimeclk = 0;
10091 //combobuf[watercheck].attributes[0]
10092 133547 }
10093
10094 133650 }
10095 [[fallthrough]];
10096 default:
10097 // call the main movement routine
10098
2/2
✓ Branch 0 taken 391624 times.
✓ Branch 1 taken 13163999 times.
13555623 if(get_qr(qr_NEW_HERO_MOVEMENT2))
10099 {
10100
2/2
✓ Branch 0 taken 37440 times.
✓ Branch 1 taken 354184 times.
391624 if(premove())
10101 354184 movehero();
10102 391624 }
10103 else
10104 {
10105 13163999 sliding = 0;
10106 13163999 moveheroOld();
10107 }
10108 13555623 }
10109
11/14
✓ Branch 0 taken 255615 times.
✓ Branch 1 taken 13907037 times.
✓ Branch 2 taken 1281 times.
✓ Branch 3 taken 254334 times.
✓ Branch 4 taken 1281 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1251 times.
✓ Branch 7 taken 30 times.
✓ Branch 8 taken 1224 times.
✓ Branch 9 taken 27 times.
✓ Branch 10 taken 1224 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1224 times.
14162652 if (isSideViewHero() && slopeid && hoverclk < 1 && !inair && fall == 0 && !IsSideSwim() && justmoved <= 0)
10110 {
10111
2/2
✓ Branch 0 taken 891 times.
✓ Branch 1 taken 333 times.
1224 if (!on_sideview_solid_oldpos(this, false, 0))
10112 {
10113 333 zfix dy = 0;
10114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 for (zfix q = 0; q <= 4; ++q)
10115 {
10116
2/2
✓ Branch 0 taken 759 times.
✓ Branch 1 taken 333 times.
1092 if (on_sideview_solid_oldpos(this, false, 0, 0, q))
10117 {
10118 333 dy = q;
10119 333 break;
10120 }
10121 759 }
10122
3/6
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 333 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 333 times.
✗ Branch 5 not taken.
5451 dy = binary_search_zfix(0, dy, [&](zfix val, zfix& retval)
10123 {
10124
2/2
✓ Branch 0 taken 1521 times.
✓ Branch 1 taken 3597 times.
5118 if (on_sideview_solid_oldpos(this, false, 0, 0, val))
10125 {
10126 1521 retval = val;
10127 1521 return BSEARCH_CONTINUE_TOWARD0;
10128 }
10129 3597 else return BSEARCH_CONTINUE_AWAY0;
10130 5118 });
10131
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 165 times.
333 if (dy) push_move(0, dy);
10132 333 }
10133 1224 }
10134
10135
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14162652 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14162652 if(shield_forcedir > -1 && action != rafting)
10136 dir = shield_forcedir;
10137
10138
10139 // check for ladder removal
10140
2/2
✓ Branch 0 taken 4414798 times.
✓ Branch 1 taken 9747854 times.
14162652 if(diagonalMovement)
10141 {
10142
2/2
✓ Branch 0 taken 4406137 times.
✓ Branch 1 taken 8661 times.
4414798 if(ladderx+laddery)
10143 {
10144
2/2
✓ Branch 0 taken 3309 times.
✓ Branch 1 taken 5352 times.
8661 if(ladderdir<=down)
10145 {
10146
10/10
✓ Branch 0 taken 2266 times.
✓ Branch 1 taken 1043 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 3241 times.
✓ Branch 4 taken 2229 times.
✓ Branch 5 taken 1012 times.
✓ Branch 6 taken 3210 times.
✓ Branch 7 taken 31 times.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 3205 times.
3309 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
10147 {
10148 104 reset_ladder();
10149 104 }
10150 3309 }
10151 else
10152 {
10153
10/10
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5347 times.
✓ Branch 2 taken 4277 times.
✓ Branch 3 taken 1070 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 5283 times.
✓ Branch 6 taken 4245 times.
✓ Branch 7 taken 1038 times.
✓ Branch 8 taken 89 times.
✓ Branch 9 taken 5194 times.
5352 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
10154 {
10155 158 reset_ladder();
10156 158 }
10157 }
10158 8661 }
10159 4414798 }
10160 else
10161 {
10162
4/4
✓ Branch 0 taken 334176 times.
✓ Branch 1 taken 9413678 times.
✓ Branch 2 taken 194313 times.
✓ Branch 3 taken 139863 times.
9747854 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
10163 {
10164 9607991 reset_ladder();
10165 9607991 }
10166 }
10167
10168
2/2
✓ Branch 0 taken 13684634 times.
✓ Branch 1 taken 478018 times.
14162652 if(!get_qr(qr_OLD_RESPAWN_POINTS)) //needs to happen after ladder removal so the respawn point is set when laddering over multiple 1 tile gaps.
10169 478018 set_respawn_point(false); //Keep the 'last safe location' updated!
10170
10171
2/2
✓ Branch 0 taken 3161 times.
✓ Branch 1 taken 14159491 times.
14162652 if(ilswim)
10172 3161 landswim++;
10173 14159491 else landswim=0;
10174
10175
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 14162480 times.
14162652 if(hopclk!=0xFF) ilswim=false;
10176
10177
4/4
✓ Branch 0 taken 35961 times.
✓ Branch 1 taken 14126691 times.
✓ Branch 2 taken 1757 times.
✓ Branch 3 taken 34204 times.
14162652 if((!loaded_guys) && (frame - newscr_clk >= 1))
10178 {
10179
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 34187 times.
34204 if(tmpscr->room==rGANON)
10180 {
10181 17 ganon_intro();
10182 17 }
10183 else
10184 {
10185 34187 loadguys();
10186 }
10187 34204 }
10188
10189
2/2
✓ Branch 0 taken 37965 times.
✓ Branch 1 taken 14124687 times.
14162652 if(frame - newscr_clk >= 2)
10190 {
10191 14124687 loadenemies();
10192 14124687 }
10193
10194 // check lots of other things
10195 14162652 checkscroll();
10196
10197
7/8
✓ Branch 0 taken 14146170 times.
✓ Branch 1 taken 16482 times.
✓ Branch 2 taken 14140374 times.
✓ Branch 3 taken 5796 times.
✓ Branch 4 taken 14140374 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 253 times.
✓ Branch 7 taken 14140121 times.
14162652 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
10198 {
10199 14140121 checkspecial();
10200 14140121 checkitems();
10201 14140121 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
10202
2/2
✓ Branch 0 taken 566904 times.
✓ Branch 1 taken 13573217 times.
14140121 if(get_qr(qr_OLD_LOCKBLOCK_COLLISION))
10203 {
10204 13573217 oldchecklockblock();
10205 13573217 oldcheckbosslockblock();
10206 13573217 }
10207
2/2
✓ Branch 0 taken 1003589 times.
✓ Branch 1 taken 13136532 times.
14140121 if(get_qr(qr_OLD_CHEST_COLLISION))
10208 {
10209 13136532 oldcheckchest(cCHEST);
10210 13136532 oldcheckchest(cLOCKEDCHEST);
10211 13136532 oldcheckchest(cBOSSCHEST);
10212 13136532 }
10213 14140121 checkpushblock();
10214 14140121 checkswordtap();
10215
10216
2/2
✓ Branch 0 taken 47275 times.
✓ Branch 1 taken 14092846 times.
14140121 if(hookshot_frozen==false)
10217 {
10218 14092846 checkspecial2(&lsave);
10219 14092846 }
10220
10221
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 14140110 times.
14140121 if(action==won)
10222 {
10223 11 return true;
10224 }
10225 14140110 }
10226
10227 // Somehow Hero was displaced from the fairy flag...
10228
3/6
✓ Branch 0 taken 23254 times.
✓ Branch 1 taken 14139387 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23254 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14162641 if(fairyclk && action != freeze && action != sideswimfreeze)
10229 {
10230 fairyclk = holdclk = refill_why = 0;
10231 }
10232
10233
4/4
✓ Branch 0 taken 14162640 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 14080780 times.
✓ Branch 3 taken 81860 times.
14162641 if((!activated_timed_warp) && (tmpscr->timedwarptics>0))
10234 {
10235 81860 tmpscr->timedwarptics--;
10236
10237
2/2
✓ Branch 0 taken 81367 times.
✓ Branch 1 taken 493 times.
81860 if(tmpscr->timedwarptics==0)
10238 {
10239 493 activated_timed_warp=true;
10240
10241
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 121 times.
493 if(tmpscr->flags4 & fTIMEDDIRECT)
10242 {
10243 121 didpit=true;
10244 121 pitx=x;
10245 121 pity=y;
10246 121 }
10247
10248 493 int32_t index2 = 0;
10249
10250
1/2
✓ Branch 0 taken 493 times.
✗ Branch 1 not taken.
493 if(tmpscr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
10251
10252 493 sdir = dir;
10253 493 dowarp(1,index2);
10254 493 }
10255 81860 }
10256
10257 14162641 bool awarp = false;
10258 //!DIMI: Global Combo Effects (AUTO STUFF)
10259
2/2
✓ Branch 0 taken 14162486 times.
✓ Branch 1 taken 2492607045 times.
2506769531 for(int32_t i=0; i<176; ++i)
10260 {
10261
2/2
✓ Branch 0 taken 83824576 times.
✓ Branch 1 taken 10221901443 times.
10305726019 for(int32_t layer=0; layer<7; ++layer)
10262 {
10263
2/2
✓ Branch 0 taken 7729294398 times.
✓ Branch 1 taken 2492607045 times.
10221901443 int32_t cid = ( layer ) ? MAPCOMBOL(layer,COMBOX(i),COMBOY(i)) : MAPCOMBO(COMBOX(i),COMBOY(i));
10264 10221901443 newcombo const& cmb = combobuf[cid];
10265
10266
2/2
✓ Branch 0 taken 586772033 times.
✓ Branch 1 taken 9635129410 times.
10221901443 if(!get_qr(qr_AUTOCOMBO_ANY_LAYER))
10267 {
10268
2/2
✓ Branch 0 taken 7226347096 times.
✓ Branch 1 taken 2408782314 times.
9635129410 if(layer > 2) break;
10269
4/4
✓ Branch 0 taken 2408782314 times.
✓ Branch 1 taken 4817564782 times.
✓ Branch 2 taken 46393952 times.
✓ Branch 3 taken 2362388362 times.
7226347096 if (layer == 1 && !get_qr(qr_AUTOCOMBO_LAYER_1)) continue;
10270
4/4
✓ Branch 0 taken 2408782314 times.
✓ Branch 1 taken 2455176420 times.
✓ Branch 2 taken 46393952 times.
✓ Branch 3 taken 2362388362 times.
4863958734 if (layer == 2 && !get_qr(qr_AUTOCOMBO_LAYER_2)) continue;
10271 2501570372 }
10272 3088342405 int32_t ind=0;
10273
10274 //AUTOMATIC TRIGGER CODE
10275
2/2
✓ Branch 0 taken 3087412625 times.
✓ Branch 1 taken 929780 times.
3088342405 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
10276 {
10277 929780 do_trigger_combo(layer, i);
10278 929780 }
10279
10280 //AUTO WARP CODE
10281
2/2
✓ Branch 0 taken 19475 times.
✓ Branch 1 taken 3088322930 times.
3088342405 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
10282 {
10283
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 3088322841 times.
3088322930 if(cmb.type==cAWARPA)
10284 {
10285 89 awarp=true;
10286 89 ind=0;
10287 89 }
10288
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 3088322778 times.
3088322841 else if(cmb.type==cAWARPB)
10289 {
10290 63 awarp=true;
10291 63 ind=1;
10292 63 }
10293
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3088322775 times.
3088322778 else if(cmb.type==cAWARPC)
10294 {
10295 3 awarp=true;
10296 3 ind=2;
10297 3 }
10298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3088322775 times.
3088322775 else if(cmb.type==cAWARPD)
10299 {
10300 awarp=true;
10301 ind=3;
10302 }
10303
1/2
✓ Branch 0 taken 3088322775 times.
✗ Branch 1 not taken.
3088322775 else if(cmb.type==cAWARPR)
10304 {
10305 awarp=true;
10306 ind=zc_oldrand()%4;
10307 }
10308 3088322930 }
10309
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 3088342250 times.
3088342405 if(awarp)
10310 {
10311
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 67 times.
155 if(tmpscr->flags5&fDIRECTAWARP)
10312 {
10313 67 didpit=true;
10314 67 pitx=x;
10315 67 pity=y;
10316 67 }
10317
10318 155 sdir = dir;
10319 155 dowarp(1,ind);
10320 155 break;
10321 }
10322 3088342250 }
10323
2/2
✓ Branch 0 taken 2492606890 times.
✓ Branch 1 taken 155 times.
2492607045 if(awarp) break;
10324 2492606890 }
10325
10326 14162641 awarp=false;
10327
10328 14162641 word c = tmpscr->numFFC();
10329
2/2
✓ Branch 0 taken 14162584 times.
✓ Branch 1 taken 424029903 times.
438192487 for(word i=0; i<c; i++)
10330 {
10331 424029903 int32_t ind=0;
10332
10333 424029903 newcombo const& cmb = combobuf[tmpscr->ffcs[i].data];
10334
10335
2/2
✓ Branch 0 taken 424018476 times.
✓ Branch 1 taken 11427 times.
424029903 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
10336 {
10337 11427 do_trigger_combo_ffc(i);
10338 11427 }
10339
10340
2/2
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 424025995 times.
424029903 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
10341 {
10342
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 424025976 times.
424025995 if(cmb.type==cAWARPA)
10343 {
10344 19 awarp=true;
10345 19 ind=0;
10346 19 }
10347
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 424025943 times.
424025976 else if(cmb.type==cAWARPB)
10348 {
10349 33 awarp=true;
10350 33 ind=1;
10351 33 }
10352
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 424025941 times.
424025943 else if(cmb.type==cAWARPC)
10353 {
10354 2 awarp=true;
10355 2 ind=2;
10356 2 }
10357
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 424025938 times.
424025941 else if(cmb.type==cAWARPD)
10358 {
10359 3 awarp=true;
10360 3 ind=3;
10361 3 }
10362
1/2
✓ Branch 0 taken 424025938 times.
✗ Branch 1 not taken.
424025938 else if(cmb.type==cAWARPR)
10363 {
10364 awarp=true;
10365 ind=zc_oldrand()%4;
10366 }
10367 424025995 }
10368
10369
2/2
✓ Branch 0 taken 424029846 times.
✓ Branch 1 taken 57 times.
424029903 if(awarp)
10370 {
10371
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(tmpscr->flags5&fDIRECTAWARP)
10372 {
10373 didpit=true;
10374 pitx=x;
10375 pity=y;
10376 }
10377
10378 57 sdir = dir;
10379 57 dowarp(1,ind);
10380 57 break;
10381 }
10382 424029846 }
10383 14162641 zfix dx, dy;
10384
7/8
✓ Branch 0 taken 255616 times.
✓ Branch 1 taken 13907025 times.
✓ Branch 2 taken 128062 times.
✓ Branch 3 taken 127554 times.
✓ Branch 4 taken 1119 times.
✓ Branch 5 taken 126943 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1119 times.
14162641 if (sideview_mode() && !on_sideview_solid_oldpos(this, false, 1) && on_sideview_solid_oldpos(this, false, 2) && !toogam)
10385 {
10386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if (slide_slope(this, dx, dy, slopeid))
10387 {
10388 1119 onplatid = 1;
10389
2/4
✓ Branch 0 taken 1119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1119 times.
1119 if (dx || dy) push_move(dx, dy);
10390 1119 }
10391 1119 }
10392
2/2
✓ Branch 0 taken 14161384 times.
✓ Branch 1 taken 1257 times.
14162641 if (onplatid <= 0) slopeid = 0;
10393 1257 else --onplatid;
10394
2/2
✓ Branch 0 taken 11255486 times.
✓ Branch 1 taken 2907155 times.
14162641 bool onplatform = (on_sideview_solid_oldpos(this, false, 1) && !Up());
10395
5/6
✓ Branch 0 taken 2909 times.
✓ Branch 1 taken 14162637 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2909 times.
✓ Branch 4 taken 2905 times.
✓ Branch 5 taken 14162641 times.
14165546 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
10396 {
10397 2905 dx = 0;
10398 2905 dy = 0;
10399
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2905 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2905 times.
2905 if (check_slope(this, true) && !toogam)
10400 {
10401 2905 slope_info const& s = get_slope(this, true).get_info();
10402 2905 bool staircheck = false;
10403
3/4
✓ Branch 0 taken 2686 times.
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 2686 times.
✗ Branch 3 not taken.
2905 if (s.slope() != slopeid && slopeid) staircheck = true;
10404
2/2
✓ Branch 0 taken 2839 times.
✓ Branch 1 taken 66 times.
2905 if (onplatform) staircheck = true;
10405 2905 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
10406
10407
4/4
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 2634 times.
✓ Branch 2 taken 270 times.
✓ Branch 3 taken 1 times.
2905 if (dx || dy)
10408 {
10409 2904 int32_t pushret = push_move(dx,dy);
10410
2/2
✓ Branch 0 taken 2886 times.
✓ Branch 1 taken 18 times.
2904 onplatform = (on_sideview_solid_oldpos(this, false, 1) && !Up());
10411
3/4
✓ Branch 0 taken 2685 times.
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 2685 times.
✗ Branch 3 not taken.
2904 if (s.slope() != slopeid && slopeid) staircheck = true;
10412
2/2
✓ Branch 0 taken 2886 times.
✓ Branch 1 taken 18 times.
2904 if (onplatform) staircheck = true;
10413
4/4
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 2628 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 219 times.
2904 if(sideview_mode() && slopeid)
10414 219 onplatid = 0;
10415
1/2
✓ Branch 0 taken 2904 times.
✗ Branch 1 not taken.
2904 if (pushret == 1)
10416 {
10417 dx = -1;
10418 dy = 0;
10419 slope_push_int(s, this, dx, dy, staircheck);
10420 push_move(0,dy);
10421 }
10422
2/2
✓ Branch 0 taken 2903 times.
✓ Branch 1 taken 1 times.
2904 if (pushret == 2)
10423 {
10424 1 dx = 0;
10425 1 dy = -1;
10426 1 slope_push_int(s, this, dx, dy, staircheck);
10427 1 push_move(dx,0);
10428 1 }
10429 2904 }
10430 2905 }
10431 2905 }
10432
10433
2/2
✓ Branch 0 taken 14162435 times.
✓ Branch 1 taken 206 times.
14162641 if(ffwarp)
10434 {
10435
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 127 times.
206 if(ffpit)
10436 {
10437 127 ffpit=false;
10438 127 didpit=true;
10439 127 pitx=x;
10440 127 pity=y;
10441 127 }
10442
10443 206 ffwarp=false;
10444 206 dowarp(1,0);
10445 206 }
10446
10447 //Hero->WarpEx
10448
2/2
✓ Branch 0 taken 14162537 times.
✓ Branch 1 taken 104 times.
14162641 if ( FFCore.warpex[wexActive] )
10449 {
10450 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
10451 104 FFCore.warpex[wexActive] = 0;
10452 104 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
10453
2/2
✓ Branch 0 taken 936 times.
✓ Branch 1 taken 104 times.
1040 for ( int32_t q = 0; q < wexActive; q++ )
10454 {
10455 936 temp_warpex[q] = FFCore.warpex[q];
10456 936 FFCore.warpex[q] = 0;
10457 936 }
10458 208 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
10459 104 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
10460 104 }
10461
10462
4/4
✓ Branch 0 taken 18640 times.
✓ Branch 1 taken 14144001 times.
✓ Branch 2 taken 28189 times.
✓ Branch 3 taken 32993 times.
14162641 if(z == 0 || !get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
10463 {
10464 // walk through bombed doors and fake walls
10465 14176994 bool walk=false;
10466 14176994 int32_t dtype=dBOMBED;
10467
10468
2/2
✓ Branch 0 taken 13819280 times.
✓ Branch 1 taken 291728 times.
14176994 if(pushing>=24) dtype=dWALK;
10469
10470
16/18
✓ Branch 0 taken 6270315 times.
✓ Branch 1 taken 7840693 times.
✓ Branch 2 taken 6133709 times.
✓ Branch 3 taken 136606 times.
✓ Branch 4 taken 6133709 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6122367 times.
✓ Branch 7 taken 11342 times.
✓ Branch 8 taken 6118946 times.
✓ Branch 9 taken 3421 times.
✓ Branch 10 taken 6111739 times.
✓ Branch 11 taken 7207 times.
✓ Branch 12 taken 6098027 times.
✓ Branch 13 taken 13712 times.
✓ Branch 14 taken 6098027 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 93084 times.
✓ Branch 17 taken 6191111 times.
14111008 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
10471 {
10472
12/14
✓ Branch 0 taken 129000 times.
✓ Branch 1 taken 6062111 times.
✓ Branch 2 taken 1018867 times.
✓ Branch 3 taken 5043244 times.
✓ Branch 4 taken 1013763 times.
✓ Branch 5 taken 5104 times.
✓ Branch 6 taken 1013763 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1013763 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 947067 times.
✓ Branch 11 taken 941963 times.
✓ Branch 12 taken 66471 times.
✓ Branch 13 taken 225 times.
6191111 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x.getInt()>112&&x.getInt()<128:x.getInt()==120) && y<=32 && tmpscr->door[0]==dtype)
10473 {
10474 225 walk=true;
10475 225 dir=up;
10476 225 }
10477
10478
12/14
✓ Branch 0 taken 129000 times.
✓ Branch 1 taken 6051903 times.
✓ Branch 2 taken 733888 times.
✓ Branch 3 taken 5318015 times.
✓ Branch 4 taken 858719 times.
✓ Branch 5 taken 4169 times.
✓ Branch 6 taken 858719 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 858719 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 815398 times.
✓ Branch 11 taken 811229 times.
✓ Branch 12 taken 43105 times.
✓ Branch 13 taken 216 times.
6180903 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x.getInt()>112&&x.getInt()<128:x.getInt()==120) && y>=128 && tmpscr->door[1]==dtype)
10479 {
10480 216 walk=true;
10481 216 dir=down;
10482 216 }
10483
10484
12/14
✓ Branch 0 taken 129000 times.
✓ Branch 1 taken 6043565 times.
✓ Branch 2 taken 47311 times.
✓ Branch 3 taken 5996254 times.
✓ Branch 4 taken 101764 times.
✓ Branch 5 taken 215 times.
✓ Branch 6 taken 101764 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 101764 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 103 times.
✓ Branch 11 taken 112 times.
✓ Branch 12 taken 101589 times.
✓ Branch 13 taken 101486 times.
6172565 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x<=32 && ((diagonalMovement||NO_GRIDLOCK)?y.getInt()>72&&y.getInt()<88:y.getInt()==80) && tmpscr->door[2]==dtype)
10485 {
10486 175 walk=true;
10487 175 dir=left;
10488 175 }
10489
10490
12/14
✓ Branch 0 taken 5969027 times.
✓ Branch 1 taken 129000 times.
✓ Branch 2 taken 42107 times.
✓ Branch 3 taken 5926920 times.
✓ Branch 4 taken 122261 times.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 122261 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 122261 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 56 times.
✓ Branch 11 taken 34 times.
✓ Branch 12 taken 122066 times.
✓ Branch 13 taken 122010 times.
6098027 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x>=208 && ((diagonalMovement||NO_GRIDLOCK)?y.getInt()>72&&y.getInt()<88:y.getInt()==80) && tmpscr->door[3]==dtype)
10491 {
10492 195 walk=true;
10493 195 dir=right;
10494 195 }
10495 6049159 }
10496
10497
2/2
✓ Branch 0 taken 14154413 times.
✓ Branch 1 taken 811 times.
14155224 if(walk)
10498 {
10499 811 hclk=0;
10500 811 drawguys=false;
10501
10502
2/2
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 195 times.
811 if(dtype==dWALK)
10503 {
10504 195 sfx(tmpscr->secretsfx);
10505
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 if(!get_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE))
10506 set_doorstate(dir);
10507 195 }
10508
10509 811 action=none; FFCore.setHeroAction(none);
10510 811 attackclk = 0;
10511 811 stepforward(29, true);
10512 811 action=scrolling; FFCore.setHeroAction(scrolling);
10513 811 pushing=false;
10514 811 }
10515 14155224 }
10516
10517
5/6
✓ Branch 0 taken 337261 times.
✓ Branch 1 taken 13846152 times.
✓ Branch 2 taken 334768 times.
✓ Branch 3 taken 2493 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 334768 times.
14183413 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
10518 {
10519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334768 times.
334768 if(heart_beep)
10520 {
10521 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
10522 }
10523 else
10524 {
10525
2/2
✓ Branch 0 taken 334242 times.
✓ Branch 1 taken 526 times.
334768 if ( heart_beep_timer == -1 )
10526 {
10527 526 heart_beep_timer = 70;
10528 526 }
10529
10530
2/2
✓ Branch 0 taken 29533 times.
✓ Branch 1 taken 305235 times.
334768 if ( heart_beep_timer > 0 )
10531 {
10532 29533 --heart_beep_timer;
10533 29533 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
10534 29533 }
10535 else
10536 {
10537 305235 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
10538 }
10539 }
10540 334768 }
10541 else
10542 {
10543
2/2
✓ Branch 0 taken 27049 times.
✓ Branch 1 taken 13827872 times.
13848645 if ( heart_beep_timer > -2 )
10544 {
10545 13827872 heart_beep_timer = -1;
10546 13827872 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
10547 13827872 }
10548 }
10549
10550
2/2
✓ Branch 0 taken 14188272 times.
✓ Branch 1 taken 1417 times.
14189689 if(rSbtn())
10551 {
10552 1417 int32_t tmp_subscr_clk = frame;
10553
10554 1417 int32_t save_type = 0;
10555
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1409 times.
✗ Branch 3 not taken.
1417 switch(lsave)
10556 {
10557 case 0:
10558 {
10559
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1368 times.
1409 if( FFCore.runScriptedActiveSusbcreen() )
10560 {
10561 41 break;
10562 }
10563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 else if ( !stopSubscreenFalling() )
10564 {
10565 1368 conveyclk=3;
10566 1368 dosubscr();
10567 1368 newscr_clk += frame - tmp_subscr_clk;
10568 1368 }
10569 1368 break;
10570 }
10571
10572
10573 case 2:
10574 save_type = 1;
10575 [[fallthrough]];
10576 case 1:
10577
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(last_savepoint_id)
10578 7 trigger_save(combobuf[last_savepoint_id]);
10579 else save_game((tmpscr->flags4&fSAVEROOM) != 0, save_type); //sanity?
10580 7 break;
10581 }
10582 1417 }
10583
10584
2/2
✓ Branch 0 taken 808699 times.
✓ Branch 1 taken 13380988 times.
14189687 if (!checkstab() )
10585 {
10586 /*
10587 for(int32_t q=0; q<176; q++)
10588 {
10589 set_bit(screengrid,q,0);
10590 }
10591
10592 for(int32_t q=0; q<MAXFFCS; q++)
10593 set_bit(ffcgrid, q, 0);
10594 */
10595 13380988 }
10596
10597 14189687 check_conveyor();
10598 14189687 PhantomsCleanup();
10599 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
10600
2/2
✓ Branch 0 taken 13986358 times.
✓ Branch 1 taken 203329 times.
14189687 if(attack==wHammer)
10601 {
10602
6/8
✓ Branch 0 taken 2170 times.
✓ Branch 1 taken 201159 times.
✓ Branch 2 taken 2170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 2165 times.
203329 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
10603 {
10604
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
✓ Branch 2 taken 508 times.
✓ Branch 3 taken 715 times.
✓ Branch 4 taken 601 times.
2165 switch(dir) //Hero's dir
10605 {
10606 case up:
10607
5/10
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 341 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 341 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 341 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 341 times.
✗ Branch 9 not taken.
341 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
10608 341 break;
10609
10610 case down:
10611
5/10
✓ Branch 0 taken 508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 508 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 508 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 508 times.
✗ Branch 9 not taken.
508 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
10612 508 break;
10613
10614 case left:
10615
5/10
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 715 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 715 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 715 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 715 times.
✗ Branch 9 not taken.
715 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
10616 715 break;
10617
10618 case right:
10619
5/10
✓ Branch 0 taken 601 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 601 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 601 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 601 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 601 times.
✗ Branch 9 not taken.
601 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
10620 601 break;
10621 }
10622
10623 2165 }
10624 203329 }
10625
10626 14189687 handleSpotlights();
10627
10628
1/2
✓ Branch 0 taken 14189687 times.
✗ Branch 1 not taken.
14189687 if(getOnSideviewLadder())
10629 {
10630 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
10631 {
10632 setOnSideviewLadder(false);
10633 }
10634 else if(CANFORCEFACEUP)
10635 {
10636 setDir(up);
10637 }
10638 }
10639
2/2
✓ Branch 0 taken 257766 times.
✓ Branch 1 taken 13931921 times.
14189687 if (justmoved > 0) --justmoved;
10640 14189687 return false;
10641 14191311 }
10642
10643 7679 bool HeroClass::push_pixel(zfix dx, zfix dy)
10644 {
10645 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
10646
3/4
✓ Branch 0 taken 3409 times.
✓ Branch 1 taken 4270 times.
✓ Branch 2 taken 3409 times.
✗ Branch 3 not taken.
7679 if(dx && dy)
10647 {
10648 bool r = push_pixel(0,dy);
10649 bool r2 = push_pixel(dx,0);
10650 return r && r2;
10651 }
10652
2/2
✓ Branch 0 taken 1568 times.
✓ Branch 1 taken 6111 times.
7679 if(dx < 0)
10653 {
10654
1/2
✓ Branch 0 taken 1568 times.
✗ Branch 1 not taken.
3136 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
10655
1/2
✓ Branch 0 taken 1568 times.
✗ Branch 1 not taken.
1568 || solpush_walkflag(x+dx,y+8,1,this)
10656
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1568 times.
✓ Branch 2 taken 1387 times.
✓ Branch 3 taken 181 times.
1568 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
10657 {
10658 1568 x += dx;
10659 1568 return true;
10660 }
10661 return false;
10662 }
10663
2/2
✓ Branch 0 taken 1841 times.
✓ Branch 1 taken 4270 times.
6111 else if(dx > 0)
10664 {
10665
2/2
✓ Branch 0 taken 1803 times.
✓ Branch 1 taken 38 times.
3666 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
10666
2/2
✓ Branch 0 taken 1825 times.
✓ Branch 1 taken 16 times.
1841 || solpush_walkflag(x+15+dx,y+8,1,this)
10667
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1526 times.
✓ Branch 3 taken 299 times.
1825 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
10668 {
10669 1803 x += dx;
10670 1803 return true;
10671 }
10672 38 return false;
10673 }
10674
2/2
✓ Branch 0 taken 2032 times.
✓ Branch 1 taken 2238 times.
4270 else if(dy < 0)
10675 {
10676
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 1 times.
4063 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
10677
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2031 times.
✓ Branch 2 taken 1723 times.
✓ Branch 3 taken 308 times.
2032 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
10678 {
10679 2031 y += dy;
10680 2031 return true;
10681 }
10682 1 return false;
10683 }
10684
1/2
✓ Branch 0 taken 2238 times.
✗ Branch 1 not taken.
2238 else if(dy > 0)
10685 {
10686
2/2
✓ Branch 0 taken 2206 times.
✓ Branch 1 taken 32 times.
4444 if(!(solpush_walkflag(x,y+15+dy,2,this)
10687
4/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 2206 times.
✓ Branch 2 taken 268 times.
✓ Branch 3 taken 1938 times.
2238 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
10688 {
10689 2206 y += dy;
10690 2206 return true;
10691 }
10692 32 return false;
10693 }
10694 return false;
10695 7679 }
10696 3564 int32_t HeroClass::push_move(zfix dx, zfix dy)
10697 {
10698 3564 int32_t ret = 0;
10699
4/4
✓ Branch 0 taken 3409 times.
✓ Branch 1 taken 5047 times.
✓ Branch 2 taken 3564 times.
✓ Branch 3 taken 4892 times.
8456 while(dx || dy)
10700 {
10701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4892 times.
4892 if(check_pitslide() != -1)
10702 break;
10703
2/2
✓ Branch 0 taken 622 times.
✓ Branch 1 taken 4270 times.
4892 if(dy)
10704 {
10705
2/2
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 3205 times.
4270 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
10706 4270 dy -= cy;
10707
2/2
✓ Branch 0 taken 4237 times.
✓ Branch 1 taken 33 times.
4270 if(!push_pixel(0,cy))
10708 {
10709 33 dy = 0;
10710 33 ret |= 2;
10711 33 }
10712 4270 }
10713
2/2
✓ Branch 0 taken 1483 times.
✓ Branch 1 taken 3409 times.
4892 if(dx)
10714 {
10715
2/2
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 2627 times.
3409 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
10716 3409 dx -= cx;
10717
2/2
✓ Branch 0 taken 3371 times.
✓ Branch 1 taken 38 times.
3409 if(!push_pixel(cx,0))
10718 {
10719 38 dx = 0;
10720 38 ret |= 1;
10721 38 }
10722 3409 }
10723 }
10724 3564 return ret;
10725 }
10726
10727 14163980 bool HeroClass::setSolid(bool set)
10728 {
10729
1/2
✓ Branch 0 taken 14163980 times.
✗ Branch 1 not taken.
14163980 bool actual = set && !toogam; //not solid when noclipping
10730 14163980 bool ret = solid_object::setSolid(actual);
10731 14163980 solid = set;
10732 14163980 return ret;
10733 }
10734
10735 18082 void HeroClass::solid_push(solid_object* obj)
10736 {
10737
1/2
✓ Branch 0 taken 18082 times.
✗ Branch 1 not taken.
18082 if(obj == this) return; //can't push self
10738
10739 18082 zfix dx, dy;
10740 18082 int32_t hdir = -1;
10741 18082 solid_push_int(obj,dx,dy,hdir,!on_ffc_platform());
10742
10743
4/4
✓ Branch 0 taken 17992 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 17756 times.
✓ Branch 3 taken 236 times.
18082 if(!dx && !dy) return;
10744
10745 326 obj->doContactDamage(hdir);
10746
10747 326 bool t = obj->getTempNonsolid();
10748 326 obj->setTempNonsolid(true);
10749
10750 326 push_move(dx,dy);
10751
10752 326 obj->setTempNonsolid(t);
10753 18082 }
10754
10755 #define COND_AWPN (get_qr(qr_SELECTAWPN) ? game->awpn : 255)
10756 #define COND_BWPN (game->bwpn)
10757 #define COND_XWPN (get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : 255)
10758 #define COND_YWPN (get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : 255)
10759 //Helper function
10760 1327 static void deselectbombsWPN(word& wpos, int32_t& BTNwpn, int32_t& directItemBTN,
10761 word f1 = 255, word f2 = 255, word f3 = 255)
10762 {
10763 1327 byte pgn = wpos&0xFF, pos = wpos>>8;
10764 1327 bool empty = pgn==255;
10765
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1327 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1327 if(empty && get_qr(qr_NO_BUTTON_VERIFY)) return; //intentional nothingness
10766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1327 times.
1327 SubscrPage* pg = new_subscreen_active->get_page(pgn==255?new_subscreen_active->curpage:pgn);
10767
1/2
✓ Branch 0 taken 1327 times.
✗ Branch 1 not taken.
1327 if(!pg)
10768 {
10769 wpos = 255; //set to nothingness
10770 return;
10771 }
10772
10773
4/6
✓ Branch 0 taken 1306 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
1327 auto fp1 = ((f1&0xFF)==255) ? 255 : ((empty || (f1&0xFF)==(wpos&0xFF)) ? f1 : 255);
10774
1/6
✓ Branch 0 taken 1327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1327 auto fp2 = ((f2&0xFF)==255) ? 255 : ((empty || (f2&0xFF)==(wpos&0xFF)) ? f2 : 255);
10775
1/6
✓ Branch 0 taken 1327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1327 auto fp3 = ((f3&0xFF)==255) ? 255 : ((empty || (f3&0xFF)==(wpos&0xFF)) ? f3 : 255);
10776 1327 auto temp = pg->movepos_legacy(SEL_VERIFY_LEFT, wpos, fp1, fp2, fp3);
10777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1327 times.
1327 if((temp&0xFF) == 0xFF)
10778 BTNwpn = -1;
10779 1327 else BTNwpn = pg->get_item_pos(temp>>8);
10780
2/2
✓ Branch 0 taken 1325 times.
✓ Branch 1 taken 2 times.
1327 directItemBTN = NEG_OR_MASK(BTNwpn,0xFFF);
10781 1327 wpos = temp;
10782 1327 }
10783 // A routine used exclusively by startwpn,
10784 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10785 1373 void HeroClass::deselectbombs(int32_t super)
10786 {
10787
6/10
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 1344 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1344 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1344 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1344 times.
1373 if ( get_qr(qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
10788
4/6
✓ Branch 0 taken 1327 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 1327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1327 times.
✗ Branch 5 not taken.
1344 if(getItemFamily(itemsbuf,Bwpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10789 {
10790
1/2
✓ Branch 0 taken 1327 times.
✗ Branch 1 not taken.
1327 if(!new_subscreen_active)
10791 return;
10792
4/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1327 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1327 times.
1327 deselectbombsWPN(game->bwpn, Bwpn, directItemB, COND_AWPN, COND_XWPN, COND_YWPN);
10793 1327 }
10794
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 else if (getItemFamily(itemsbuf,Xwpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10795 {
10796 if(!new_subscreen_active)
10797 return;
10798 deselectbombsWPN(game->xwpn, Xwpn, directItemX, COND_AWPN, COND_BWPN, COND_YWPN);
10799 }
10800
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 else if (getItemFamily(itemsbuf,Ywpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10801 {
10802 if(!new_subscreen_active)
10803 return;
10804 deselectbombsWPN(game->ywpn, Ywpn, directItemY, COND_AWPN, COND_XWPN, COND_BWPN);
10805 }
10806
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 else if (getItemFamily(itemsbuf,Awpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Awpn==directWpn))
10807 {
10808 if(!new_subscreen_active)
10809 return;
10810 deselectbombsWPN(game->awpn, Awpn, directItemA, COND_BWPN, COND_XWPN, COND_YWPN);
10811 }
10812 1373 }
10813
10814 int32_t potion_life=0;
10815 int32_t potion_magic=0;
10816
10817 13558331 bool HeroClass::onWater(bool drownonly)
10818 {
10819 13558331 int32_t water = 0;
10820 13558331 int32_t types[4] = {0};
10821 13558331 int32_t x1 = x+4, x2 = x+11,
10822 13558331 y1 = y+9, y2 = y+15;
10823
2/2
✓ Branch 0 taken 1063177 times.
✓ Branch 1 taken 12495154 times.
13558331 if (get_qr(qr_SMARTER_WATER))
10824 {
10825
4/4
✓ Branch 0 taken 10733 times.
✓ Branch 1 taken 1052444 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 8349 times.
1071548 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
10826
2/2
✓ Branch 0 taken 9619 times.
✓ Branch 1 taken 1114 times.
10733 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
10827
2/2
✓ Branch 0 taken 8371 times.
✓ Branch 1 taken 1248 times.
9619 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
10828 8371 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10829 1063177 }
10830 else
10831 {
10832 12495154 types[0] = COMBOTYPE(x1,y1);
10833
10834
2/2
✓ Branch 0 taken 12374584 times.
✓ Branch 1 taken 120570 times.
12495154 if(MAPFFCOMBO(x1,y1))
10835 120570 types[0] = FFCOMBOTYPE(x1,y1);
10836
10837 12495154 types[1] = COMBOTYPE(x1,y2);
10838
10839
2/2
✓ Branch 0 taken 12389134 times.
✓ Branch 1 taken 106020 times.
12495154 if(MAPFFCOMBO(x1,y2))
10840 106020 types[1] = FFCOMBOTYPE(x1,y2);
10841
10842 12495154 types[2] = COMBOTYPE(x2,y1);
10843
10844
2/2
✓ Branch 0 taken 12373552 times.
✓ Branch 1 taken 121602 times.
12495154 if(MAPFFCOMBO(x2,y1))
10845 121602 types[2] = FFCOMBOTYPE(x2,y1);
10846
10847 12495154 types[3] = COMBOTYPE(x2,y2);
10848
10849
2/2
✓ Branch 0 taken 12386204 times.
✓ Branch 1 taken 108950 times.
12495154 if(MAPFFCOMBO(x2,y2))
10850 108950 types[3] = FFCOMBOTYPE(x2,y2);
10851
10852 12495154 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10853
2/2
✓ Branch 0 taken 12380031 times.
✓ Branch 1 taken 115123 times.
12495154 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10854 115123 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10855
10856
5/6
✓ Branch 0 taken 223017 times.
✓ Branch 1 taken 12272137 times.
✓ Branch 2 taken 214266 times.
✓ Branch 3 taken 8751 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 205928 times.
12701082 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10857
4/4
✓ Branch 0 taken 206169 times.
✓ Branch 1 taken 8097 times.
✓ Branch 2 taken 205928 times.
✓ Branch 3 taken 241 times.
214266 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10858 205928 water = typec;
10859 }
10860
2/2
✓ Branch 0 taken 13344054 times.
✓ Branch 1 taken 214277 times.
13558331 if(water > 0)
10861 {
10862
1/2
✓ Branch 0 taken 214277 times.
✗ Branch 1 not taken.
214277 if(!drownonly) return true;
10863
7/8
✓ Branch 0 taken 139216 times.
✓ Branch 1 taken 75061 times.
✓ Branch 2 taken 139213 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2249 times.
✓ Branch 5 taken 136964 times.
✓ Branch 6 taken 2249 times.
✗ Branch 7 not taken.
214277 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
10864 {
10865 75064 return true;
10866 }
10867 139213 }
10868 13483267 return false;
10869 13558331 }
10870
10871 bool HeroClass::mirrorBonk()
10872 {
10873 zfix tx = x, ty = y, tz = z;
10874 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10875 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10876 execute(info);
10877 bool fail = info.isUnwalkable();
10878
10879 if(!fail) //not solid, but check for water/pits...
10880 {
10881 if(onWater(true))
10882 fail = true;
10883 if(pitslide() || fallclk)
10884 fail = true;
10885 fallclk = 0;
10886 }
10887 x = tx; y = ty; z = tz;
10888 return fail;
10889 }
10890
10891 void HeroClass::doMirror(int32_t mirrorid)
10892 {
10893 if(z > 0 || fakez > 0) return; //No mirror in air
10894 if(mirrorid < 0)
10895 mirrorid = current_item_id(itype_mirror);
10896 if(mirrorid < 0) return;
10897
10898 if((tmpscr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10899 {
10900 item_error();
10901 return;
10902 }
10903 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10904 int32_t posarr[] = {COMBOPOS(x+sens,y+sens), COMBOPOS(x+sens,y+15-sens),
10905 COMBOPOS(x+15-sens,y+sens), COMBOPOS(x+15-sens,y+15-sens)};
10906 for(auto pos : posarr)
10907 {
10908 if(HASFLAG_ANY(mfNOMIRROR, pos)) //"No Mirror" flag touching the player
10909 {
10910 item_error();
10911 return;
10912 }
10913 }
10914
10915 itemdata const& mirror = itemsbuf[mirrorid];
10916 if(DMaps[currdmap].flags & dmfMIRRORCONTINUE)
10917 {
10918 paymagiccost(mirrorid);
10919 if(mirror.usesound2) sfx(mirror.usesound2);
10920
10921 doWarpEffect(mirror.misc2, true);
10922 if(mirror.flags & ITEM_FLAG2) //Act as F6->Continue
10923 {
10924 Quit = qCONT;
10925 skipcont = 1;
10926 }
10927 else //Act as Divine Escape
10928 {
10929 int32_t div_prot_temp=div_prot_item;
10930 restart_level();
10931 div_prot_item=div_prot_temp;
10932 magicitem=-1;
10933 magiccastclk=0;
10934 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10935 }
10936 }
10937 else
10938 {
10939 int32_t destdmap = DMaps[currdmap].mirrorDMap;
10940 int32_t offscr = currscr - DMaps[currdmap].xoff;
10941 if(destdmap < 0)
10942 return;
10943 int32_t destscr = DMaps[destdmap].xoff + offscr;
10944 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10945 return;
10946 paymagiccost(mirrorid);
10947
10948 //Store some values to restore if 'warp fails'
10949 int32_t tLastEntrance = lastentrance,
10950 tLastEntranceDMap = lastentrance_dmap,
10951 tContScr = game->get_continue_scrn(),
10952 tContDMap = game->get_continue_dmap(),
10953 tPortalDMap = game->saved_mirror_portal.srcdmap;
10954 int32_t sourcescr = currscr, sourcedmap = currdmap;
10955 zfix tx = x, ty = y, tz = z;
10956 game->saved_mirror_portal.srcdmap = -1;
10957 action = none; FFCore.setHeroAction(none);
10958
10959 //Warp to new dmap
10960 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10961 mirror.usesound, 0, -1);
10962
10963 //Check for valid landing location
10964 if(mirrorBonk()) //Invalid landing, warp back!
10965 {
10966 action = none; FFCore.setHeroAction(none);
10967 lastentrance = tLastEntrance;
10968 lastentrance_dmap = tLastEntranceDMap;
10969 game->set_continue_scrn(tContScr);
10970 game->set_continue_dmap(tContDMap);
10971 x = tx;
10972 y = ty;
10973 z = tz;
10974 game->saved_mirror_portal.srcdmap = tPortalDMap;
10975 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10976 mirror.usesound, 0, -1);
10977 }
10978 else if(mirror.flags & ITEM_FLAG1) //Place portal!
10979 {
10980 //Place the portal
10981 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10982 //Since it was placed after loading this screen, load the portal object now
10983 game->load_portal();
10984 //Don't immediately trigger the warp back
10985 mirror_portal.prox_active = false;
10986
10987 //Set continue point
10988 if(currdmap != game->get_continue_dmap())
10989 {
10990 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
10991 }
10992 game->set_continue_dmap(currdmap);
10993 lastentrance_dmap = currdmap;
10994 lastentrance = game->get_continue_scrn();
10995 }
10996 }
10997 }
10998
10999 14162652 void HeroClass::handle_passive_buttons()
11000 {
11001 14162652 do_liftglove(-1,true);
11002 14162652 do_jump(-1,true);
11003 14162652 }
11004
11005 static bool did_passive_jump = false;
11006 14163069 bool HeroClass::do_jump(int32_t jumpid, bool passive)
11007 {
11008
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 14162652 times.
14163069 if(passive) did_passive_jump = false;
11009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417 times.
417 else if(did_passive_jump) return false; //don't jump twice in the same frame
11010
11011
2/2
✓ Branch 0 taken 604738 times.
✓ Branch 1 taken 13558331 times.
14163069 if(nomove_action(action)) return false; //can't jump while ex. drowning
11012
2/2
✓ Branch 0 taken 75064 times.
✓ Branch 1 taken 13483267 times.
13558331 if(onWater(true)) return false; //Don't allow jumping off of water frame-perfectly...
11013
11014
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 13482852 times.
13483267 if(jumpid < 0)
11015 13482852 jumpid = current_item_id(itype_rocs,true,true);
11016
11017
2/2
✓ Branch 0 taken 13141088 times.
✓ Branch 1 taken 342179 times.
13483267 if(unsigned(jumpid) >= MAXITEMS) return false;
11018
4/4
✓ Branch 0 taken 340952 times.
✓ Branch 1 taken 1227 times.
✓ Branch 2 taken 1935 times.
✓ Branch 3 taken 339017 times.
342179 if(inlikelike || charging) return false;
11019
1/2
✓ Branch 0 taken 339017 times.
✗ Branch 1 not taken.
339017 if(!checkitem_jinx(jumpid)) return false;
11020
11021 339017 itemdata const& itm = itemsbuf[jumpid];
11022
11023 339017 bool standing = isStanding(true);
11024
3/4
✓ Branch 0 taken 323404 times.
✓ Branch 1 taken 15613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15613 times.
339017 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
11025
4/6
✓ Branch 0 taken 339017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15613 times.
✓ Branch 3 taken 323404 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15613 times.
339017 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
11026
2/4
✓ Branch 0 taken 323404 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 323404 times.
323404 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
11027 {
11028 item_error();
11029 return false;
11030 }
11031
11032 323404 byte intbtn = byte(itm.misc2&0xFF);
11033
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 323010 times.
323404 if(passive)
11034 {
11035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 323010 times.
323010 if(!getIntBtnInput(intbtn, true, true, false, false, true))
11036 323010 return false; //not pressed
11037 }
11038
11039 394 paymagiccost(jumpid);
11040
11041
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(!standing)
11042 {
11043 ++extra_jump_count;
11044 fall = 0;
11045 fakefall = 0;
11046 if(hoverclk > 0)
11047 hoverclk = -hoverclk;
11048 }
11049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if(itm.flags & ITEM_FLAG1)
11050 setFall(fall - itm.power);
11051 394 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
11052 394 coyotetime = 65535; //jumped, so no coyotetime
11053 394 setOnSideviewLadder(false);
11054
11055 // Reset the ladder, unless on an unwalkable combo
11056
6/10
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 393 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 394 times.
✗ Branch 9 not taken.
394 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,SWITCHBLOCK_STATE)))
11057 reset_ladder();
11058
11059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if(itm.usesound)
11060 394 sfx(itm.usesound,pan(x.getInt()));
11061
11062
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(passive)
11063 {
11064 did_passive_jump = true;
11065 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
11066 }
11067 394 return true;
11068 14163069 }
11069 11803 void HeroClass::drop_liftwpn()
11070 {
11071
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11802 times.
11803 if(!lift_wpn) return;
11072
11073 1 handle_lift(false); //sets position properly, accounting for large weapons
11074 1 auto liftid = current_item_id(itype_liftglove,true,true);
11075 1 itemdata const& glove = itemsbuf[liftid];
11076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(isSideViewGravity())
11077 {
11078 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
11079 }
11080 else
11081 {
11082 1 auto lheight = liftheight+z+fakez;
11083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(glove.flags & ITEM_FLAG1)
11084 {
11085 lift_wpn->z = 0;
11086 lift_wpn->fakez = lheight;
11087 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
11088 }
11089 else
11090 {
11091 1 lift_wpn->z = lheight;
11092 1 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
11093 }
11094 }
11095 1 lift_wpn->dir = dir;
11096 1 lift_wpn->step = 0;
11097 1 lift_wpn->fakefall = 0;
11098 1 lift_wpn->fall = 0;
11099 1 Lwpns.add(lift_wpn);
11100 1 lift_wpn = nullptr;
11101 11803 }
11102 14162652 void HeroClass::do_liftglove(int32_t liftid, bool passive)
11103 {
11104
2/2
✓ Branch 0 taken 11065 times.
✓ Branch 1 taken 14151587 times.
14162652 if(!lift_wpn)
11105 14151587 last_lift_id.reset();
11106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14162652 times.
14162652 if(liftid < 0)
11107 {
11108
4/4
✓ Branch 0 taken 10228 times.
✓ Branch 1 taken 14152424 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 9449 times.
14162652 if(last_lift_id && can_lift(*last_lift_id))
11109 9449 liftid = *last_lift_id;
11110 14153203 else liftid = current_item_id(itype_liftglove,true,true);
11111 14162652 }
11112
2/2
✓ Branch 0 taken 364561 times.
✓ Branch 1 taken 13798091 times.
14162652 if(!can_lift(liftid)) return;
11113 364561 itemdata const& glove = itemsbuf[liftid];
11114 364561 byte intbtn = byte(glove.misc1&0xFF);
11115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 364561 times.
364561 if(passive)
11116 {
11117
2/2
✓ Branch 0 taken 2270 times.
✓ Branch 1 taken 362291 times.
364561 if(!getIntBtnInput(intbtn, true, true, false, false, true))
11118 362291 return; //not pressed
11119 2270 }
11120
11121 2270 bool had_weapon = lift_wpn;
11122
11123
3/4
✓ Branch 0 taken 2203 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 2203 times.
✗ Branch 3 not taken.
4473 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
11124
1/2
✓ Branch 0 taken 2203 times.
✗ Branch 1 not taken.
2203 (checkbunny(liftid) && checkmagiccost(liftid))))
11125 {
11126 item_error();
11127 return;
11128 }
11129
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2270 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2270 if(glove.script!=0 && (FFCore.doscript(ScriptType::Item, liftid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
11130 return;
11131
11132 2270 bool paidmagic = had_weapon; //don't pay to throw, only to lift
11133
1/2
✓ Branch 0 taken 2270 times.
✗ Branch 1 not taken.
2270 if(glove.script)
11134 {
11135 if(!paidmagic)
11136 {
11137 paidmagic = true;
11138 paymagiccost(liftid);
11139 }
11140
11141 int i = liftid;
11142 FFCore.reset_script_engine_data(ScriptType::Item, i);
11143 ZScriptVersion::RunScript(ScriptType::Item, glove.script, i);
11144 FFCore.deallocateAllScriptOwned(ScriptType::Item,i);
11145
11146 bool has_weapon = lift_wpn;
11147 if(has_weapon != had_weapon) //Item action script changed the lift information
11148 {
11149 if(passive)
11150 {
11151 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
11152 }
11153 return;
11154 }
11155 }
11156
11157
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 2203 times.
2270 if(lift_wpn)
11158 {
11159
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(!paidmagic)
11160 {
11161 paidmagic = true;
11162 paymagiccost(liftid);
11163 }
11164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(!liftclk)
11165 {
11166 //Throw the weapon!
11167 //hero's direction and position
11168 67 handle_lift(false); //sets position properly, accounting for large weapons
11169
11170 67 lift_wpn->dir = dir;
11171 //Configured throw speed in both axes
11172 67 auto basestep = glove.misc2;
11173 67 lift_wpn->step = zfix(basestep)/100;
11174
11175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(isSideViewGravity())
11176 {
11177 lift_wpn->fall = -glove.misc3;
11178 switch(dir)
11179 {
11180 case left: case right:
11181 break; //nothing special for sideways
11182 case up: //step converts to upwards fall
11183 lift_wpn->fall -= basestep;
11184 lift_wpn->step = 0;
11185 break;
11186 case down: //step converts into straight down fall
11187 lift_wpn->fall = zc_min(basestep,zinit.terminalv);
11188 lift_wpn->step = 0;
11189 break;
11190 }
11191 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
11192 }
11193 else
11194 {
11195 67 auto lheight = liftheight+z+fakez;
11196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(glove.flags & ITEM_FLAG1)
11197 {
11198 lift_wpn->z = 0;
11199 lift_wpn->fakez = lheight;
11200 lift_wpn->fakefall = -glove.misc3;
11201 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
11202 }
11203 else
11204 {
11205 67 lift_wpn->z = lheight;
11206 67 lift_wpn->fall = -glove.misc3;
11207 67 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
11208 }
11209 }
11210 67 Lwpns.add(lift_wpn);
11211 67 lift_wpn = nullptr;
11212 67 last_lift_id.reset();
11213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(glove.usesound2)
11214 67 sfx(glove.usesound2,pan(int32_t(x)));
11215 67 }
11216 else last_lift_id = liftid;
11217
11218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(passive)
11219 {
11220 67 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
11221 67 }
11222 67 return;
11223 }
11224
11225 2203 bool lifted = false;
11226 //Check for a liftable weapon
11227 //if(!lifted)
11228 {
11229 2203 zfix hx, hy, hw, hh;
11230
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✓ Branch 2 taken 581 times.
✓ Branch 3 taken 672 times.
✓ Branch 4 taken 599 times.
2203 switch(dir)
11231 {
11232 case up:
11233 351 hx = x;
11234 351 hy = y-8;
11235 351 hw = 16;
11236 351 hh = bigHitbox ? 8 : 16;
11237 351 break;
11238 case down:
11239 581 hx = x;
11240 581 hy = y+16;
11241 581 hw = 16;
11242 581 hh = 8;
11243 581 break;
11244 case left:
11245 672 hx = x-8;
11246 672 hy = y;
11247 672 hw = 8;
11248 672 hh = 16;
11249 672 break;
11250 case right:
11251 599 hx = x+16;
11252 599 hy = y;
11253 599 hw = 8;
11254 599 hh = 16;
11255 599 break;
11256 }
11257
2/2
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 113 times.
2314 for(int32_t q = 0; q < Lwpns.Count(); ++q)
11258 {
11259 113 weapon* w = (weapon*)Lwpns.spr(q);
11260
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 103 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
113 if((w->lift_level && w->lift_level <= glove.fam_type))
11261 {
11262
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if(!w->hit(hx,hy,0,hw,hh,1))
11263 8 continue;
11264 2 lift(w, w->lift_time, w->lift_height);
11265 2 Lwpns.remove(w);
11266 2 lifted = true;
11267 2 break;
11268 }
11269 103 }
11270 }
11271
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2201 times.
2203 if(!lifted) //Check for a liftable combo
11272 {
11273 2201 zfix bx, by;
11274 2201 zfix bx2, by2;
11275
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✓ Branch 2 taken 581 times.
✓ Branch 3 taken 672 times.
✓ Branch 4 taken 597 times.
2201 switch(dir)
11276 {
11277 case up:
11278 351 by = y + (bigHitbox ? -2 : 6);
11279 351 by2 = by;
11280 351 bx = x + 4;
11281 351 bx2 = bx + 8;
11282 351 break;
11283 case down:
11284 581 by = y + 17;
11285 581 by2 = by;
11286 581 bx = x + 4;
11287 581 bx2 = bx + 8;
11288 581 break;
11289 case left:
11290 672 by = y + (bigHitbox ? 0 : 8);
11291 672 by2 = y + 8;
11292 672 bx = x - 2;
11293 672 bx2 = x - 2;
11294 672 break;
11295 case right:
11296 597 by = y + (bigHitbox ? 0 : 8);
11297 597 by2 = y + 8;
11298 597 bx = x + 17;
11299 597 bx2 = x + 17;
11300 597 break;
11301 }
11302 2201 int32_t pos = COMBOPOS_B(bx,by);
11303 2201 int32_t pos2 = COMBOPOS_B(bx2,by2);
11304 2201 int32_t foundpos = -1;
11305
11306
2/2
✓ Branch 0 taken 2152 times.
✓ Branch 1 taken 15383 times.
17535 for(auto lyr = 6; lyr >= 0; --lyr)
11307 {
11308 15383 mapscr* scr = FFCore.tempScreens[lyr];
11309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15383 times.
15383 if(pos > -1)
11310 {
11311 15383 newcombo const& cmb = combobuf[scr->data[pos]];
11312
2/2
✓ Branch 0 taken 15337 times.
✓ Branch 1 taken 46 times.
15383 if(cmb.liftflags & LF_LIFTABLE)
11313 {
11314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(do_lift_combo(lyr,pos,liftid))
11315 {
11316 46 lifted = true;
11317 46 break;
11318 }
11319 }
11320 15337 }
11321
3/4
✓ Branch 0 taken 2209 times.
✓ Branch 1 taken 13128 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2209 times.
15337 if(pos != pos2 && pos2 > -1)
11322 {
11323 2209 newcombo const& cmb2 = combobuf[scr->data[pos2]];
11324
2/2
✓ Branch 0 taken 2206 times.
✓ Branch 1 taken 3 times.
2209 if(cmb2.liftflags & LF_LIFTABLE)
11325 {
11326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(do_lift_combo(lyr,pos2,liftid))
11327 {
11328 3 lifted = true;
11329 3 break;
11330 }
11331 }
11332 2206 }
11333 15334 }
11334 2201 }
11335
11336
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 2152 times.
2203 if(!lifted)
11337 {
11338 2152 last_lift_id.reset();
11339 2152 return;
11340 }
11341 51 last_lift_id = liftid;
11342
11343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(!paidmagic)
11344 {
11345 51 paidmagic = true;
11346 51 paymagiccost(liftid);
11347 51 }
11348 51 set_liftflags(liftid);
11349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(passive)
11350 51 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
11351 51 return;
11352 14162652 }
11353 23089 void HeroClass::handle_lift(bool dec)
11354 {
11355
1/2
✓ Branch 0 taken 23089 times.
✗ Branch 1 not taken.
23089 if(lift_wpn)
11356 23089 lift_wpn->fakez = 0;
11357 else liftclk = 0;
11358
2/2
✓ Branch 0 taken 21144 times.
✓ Branch 1 taken 1945 times.
23089 if(liftclk <= (dec?1:0))
11359 {
11360 21144 liftclk = 0;
11361 21144 tliftclk = 0;
11362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21144 times.
21144 if(lift_wpn)
11363 {
11364
2/4
✓ Branch 0 taken 21144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21144 times.
21144 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
11365 {
11366 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
11367 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
11368 }
11369 else
11370 {
11371 21144 lift_wpn->x = x;
11372 21144 lift_wpn->y = y;
11373 }
11374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21144 times.
21144 if(isSideViewGravity())
11375 lift_wpn->y -= liftheight;
11376 21144 else lift_wpn->z = liftheight;
11377 21144 }
11378
2/2
✓ Branch 0 taken 21076 times.
✓ Branch 1 taken 68 times.
21144 if(action == lifting)
11379 {
11380 68 action = none; FFCore.setHeroAction(none);
11381 68 }
11382 21144 return;
11383 }
11384
2/2
✓ Branch 0 taken 981 times.
✓ Branch 1 taken 964 times.
1945 if(dec) --liftclk;
11385 double xdist, ydist;
11386 1945 double perc = (liftclk/double(tliftclk));
11387
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
✓ Branch 2 taken 285 times.
✓ Branch 3 taken 574 times.
✓ Branch 4 taken 738 times.
1945 switch(dir)
11388 {
11389 case up:
11390 {
11391 348 xdist = 0;
11392 348 ydist = -16;
11393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
348 if(lift_wpn->txsz > 1)
11394 {
11395 xdist = -((lift_wpn->txsz*8)-8);
11396 }
11397 348 else xdist = 0;
11398
1/2
✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
348 if(lift_wpn->tysz > 1)
11399 {
11400 ydist = -(lift_wpn->tysz*16);
11401 }
11402 348 ydist *= perc;
11403 348 break;
11404 }
11405 case down:
11406 {
11407 285 xdist = 0;
11408 285 ydist = 16;
11409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
285 if(lift_wpn->txsz > 1)
11410 {
11411 xdist = -((lift_wpn->txsz*8)-8);
11412 }
11413 285 else xdist = 0;
11414 285 ydist *= perc;
11415 285 break;
11416 }
11417 case left:
11418 {
11419 574 xdist = -16;
11420 574 ydist = 0;
11421
1/2
✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
574 if(lift_wpn->txsz > 1)
11422 {
11423 xdist = -(lift_wpn->txsz*16);
11424 }
11425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 574 times.
574 if(lift_wpn->tysz > 1)
11426 {
11427 ydist = -((lift_wpn->tysz*8)-8);
11428 }
11429 574 else ydist = 0;
11430 574 xdist *= perc;
11431 574 break;
11432 }
11433 case right:
11434 {
11435 738 xdist = 16;
11436 738 ydist = 0;
11437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 738 times.
738 if(lift_wpn->tysz > 1)
11438 {
11439 ydist = -((lift_wpn->tysz*8)-8);
11440 }
11441 738 else ydist = 0;
11442 738 xdist *= perc;
11443 738 break;
11444 }
11445 }
11446
11447 1945 lift_wpn->x = x + xdist;
11448 1945 lift_wpn->y = y + ydist;
11449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1945 times.
1945 if(isSideViewGravity())
11450 lift_wpn->y -= liftheight*(1.0-perc);
11451 1945 else lift_wpn->z = liftheight*(1.0-perc);
11452 23089 }
11453 14172929 bool HeroClass::can_lift(int32_t gloveid)
11454 {
11455
2/2
✓ Branch 0 taken 13734721 times.
✓ Branch 1 taken 438208 times.
14172929 if(unsigned(gloveid) >= MAXITEMS) return false;
11456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 438208 times.
438208 if(lstunclock) return false;
11457
1/2
✓ Branch 0 taken 438208 times.
✗ Branch 1 not taken.
438208 if(!checkitem_jinx(gloveid)) return false;
11458 438208 itemdata const& glove = itemsbuf[gloveid];
11459
3/3
✓ Branch 0 taken 57396 times.
✓ Branch 1 taken 374059 times.
✓ Branch 2 taken 6753 times.
438208 switch(action)
11460 {
11461 case none: case walking:
11462 374059 break;
11463
11464 case swimming:
11465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6753 times.
6753 if(glove.flags & ITEM_FLAG2)
11466 break;
11467 6753 return false;
11468
11469 default:
11470 57396 return false;
11471 }
11472 374059 return true;
11473 14172929 }
11474 68 void HeroClass::lift(weapon* w, byte timer, zfix height)
11475 {
11476 68 lift_wpn = w;
11477 68 liftclk = timer;
11478 68 tliftclk = timer;
11479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(height < 0)
11480 liftheight = 0;
11481 68 else liftheight = height;
11482 68 }
11483
11484 137 void HeroClass::doSwitchHook(byte style)
11485 {
11486 137 hs_switcher = true;
11487 137 pull_hero = true;
11488 //{ Load hook weapons, set them to obey special drawing
11489 137 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
11490 137 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
11491
11492
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1 times.
137 if(w)
11493 1 w->switch_hooked = true;
11494
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1 times.
137 if(hw)
11495 1 hw->switch_hooked = true;
11496
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 137 times.
142 for(int32_t j=0; j<chainlinks.Count(); j++)
11497 {
11498 5 chainlinks.spr(j)->switch_hooked = true;
11499 5 }
11500 //}
11501
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 132 times.
137 if(hooked_combopos > -1)
11502 {
11503
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11504 132 hooked_layerbits = 0;
11505
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 132 times.
1056 for(auto q = 0; q < 7; ++q)
11506 924 hooked_undercombos[q] = -1;
11507 132 uint16_t plpos = COMBOPOS(x+8,y+8);
11508
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 132 times.
1056 for(auto q = max_layer; q > -1; --q)
11509 {
11510 924 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[hooked_combopos]];
11511 924 newcombo const& comb2 = combobuf[FFCore.tempScreens[q]->data[plpos]];
11512 924 int32_t fl1 = FFCore.tempScreens[q]->sflag[hooked_combopos],
11513 924 fl2 = FFCore.tempScreens[q]->sflag[plpos];
11514 924 bool isPush = false;
11515
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 132 times.
924 if(isSwitchHookable(cmb))
11516 {
11517
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.type == cSWITCHHOOK)
11518 {
11519 132 uint16_t plpos = COMBOPOS(x+8,y+8);
11520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
132 if((cmb.usrflags&cflag1) && FFCore.tempScreens[q]->data[plpos])
11521 continue; //don't swap with non-zero combo
11522
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 132 times.
132 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
11523 continue; //too low a switchhook level
11524 132 hooked_layerbits |= 1<<q; //Swapping
11525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(cmb.usrflags&cflag3)
11526 {
11527 if(cmb.usrflags&cflag6)
11528 {
11529 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
11530 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
11531 }
11532 else
11533 {
11534 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
11535 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
11536 }
11537 }
11538 else
11539 {
11540 132 hooked_layerbits |= 1<<(q+8); //Swapping BACK
11541
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag7) //counts as 'pushblock'
11542 isPush = true;
11543 }
11544 132 }
11545 else if(isCuttableType(cmb.type))
11546 {
11547 if(isCuttableNextType(cmb.type))
11548 {
11549 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
11550 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
11551 }
11552 else
11553 {
11554 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
11555 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
11556 }
11557 hooked_layerbits |= 1<<q; //Swapping
11558 }
11559 else
11560 {
11561 hooked_layerbits |= 1<<q; //Swapping
11562 hooked_layerbits |= 1<<(q+8); //Swapping BACK
11563 }
11564 132 }
11565
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 132 times.
924 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
11566 {
11567
3/6
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 132 times.
✗ Branch 5 not taken.
132 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
11568 132 && hasMainGuy())
11569 {
11570 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
11571 continue;
11572 }
11573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(fl1 == mfPUSHED)
11574 {
11575 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
11576 continue;
11577 }
11578
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(fl1)
11579 {
11580 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
11581 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
11582 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
11583 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
11584 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
11585 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
11586 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
11587 isPush = true;
11588 132 }
11589
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(cmb.flag)
11590 {
11591 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
11592 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
11593 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
11594 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
11595 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
11596 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
11597 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
11598 isPush = true;
11599 132 }
11600
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(isPush) //Check for block holes / triggers
11601 {
11602 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
11603 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
11604 {
11605 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
11606 }
11607 else if(!get_qr(qr_BLOCKHOLE_SAME_ONLY))
11608 {
11609 auto maxLayer = get_qr(qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
11610 for(auto lyr = 0; lyr < maxLayer; ++lyr)
11611 {
11612 if(lyr == q) continue;
11613 switch(FFCore.tempScreens[q]->sflag[plpos])
11614 {
11615 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
11616 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
11617 lyr=7;
11618 break;
11619 }
11620 switch(combobuf[FFCore.tempScreens[q]->data[plpos]].flag)
11621 {
11622 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
11623 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
11624 lyr=7;
11625 break;
11626 }
11627 }
11628 }
11629 }
11630 132 }
11631 924 }
11632 132 }
11633 137 switch_hooked = true;
11634 137 switchhookstyle = style;
11635
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
137 switch(style)
11636 {
11637 default: case swPOOF:
11638 {
11639 1 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
11640
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
11641
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(x, y, dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_combopos > -1)
11643 decorations.add(new comboSprite((zfix)COMBOX(hooked_combopos), (zfix)COMBOY(hooked_combopos), dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object)
11645
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(switching_object->x, switching_object->y, dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11646 1 break;
11647 }
11648 case swFLICKER:
11649 {
11650 136 switchhookmaxtime = switchhookclk = 64;
11651 136 break;
11652 }
11653 case swRISE:
11654 {
11655 switchhookmaxtime = switchhookclk = 64;
11656 break;
11657 }
11658 }
11659 137 }
11660
11661 46406 bool HeroClass::startwpn(int32_t itemid)
11662 {
11663
1/2
✓ Branch 0 taken 46406 times.
✗ Branch 1 not taken.
46406 if(itemid < 0) return false;
11664 46406 itemdata const& itm = itemsbuf[itemid];
11665
6/6
✓ Branch 0 taken 10749 times.
✓ Branch 1 taken 35657 times.
✓ Branch 2 taken 8654 times.
✓ Branch 3 taken 27003 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 116 times.
46523 if(((dir==up && y<24) || (dir==down && y>128) ||
11666
6/6
✓ Branch 0 taken 13112 times.
✓ Branch 1 taken 13891 times.
✓ Branch 2 taken 13885 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 117 times.
✓ Branch 5 taken 46283 times.
46406 (dir==left && x<32) || (dir==right && x>208)) && !(get_qr(qr_ITEMSONEDGES) || inlikelike))
11667 116 return false;
11668
11669
1/2
✓ Branch 0 taken 46290 times.
✗ Branch 1 not taken.
46290 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
11670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46290 times.
46290 if(liftonly)
11671 {
11672 dowpn = -1;
11673 switch(itm.family)
11674 {
11675 case itype_bomb:
11676 case itype_sbomb:
11677 if(itm.flags & ITEM_FLAG4)
11678 do_liftglove(-1,false);
11679 break;
11680 case itype_liftglove:
11681 do_liftglove(-1,false);
11682 break;
11683 }
11684 return false;
11685 }
11686
11687 46290 int32_t wx=x;
11688 46290 int32_t wy=y-fakez;
11689 46290 int32_t wz=z;
11690 46290 bool ret = true;
11691
11692
5/5
✓ Branch 0 taken 13851 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 10730 times.
✓ Branch 3 taken 8622 times.
✓ Branch 4 taken 13081 times.
46290 switch(dir)
11693 {
11694 case up:
11695 10730 wy-=16;
11696 10730 break;
11697
11698 case down:
11699 8622 wy+=16;
11700 8622 break;
11701
11702 case left:
11703 13081 wx-=16;
11704 13081 break;
11705
11706 case right:
11707 13851 wx+=16;
11708 13851 break;
11709 }
11710
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46290 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46290 if (IsSideSwim() && (itm.flags & ITEM_SIDESWIM_DISABLED)) return false;
11711
11712
17/27
✗ Branch 0 not taken.
✓ Branch 1 taken 2484 times.
✓ Branch 2 taken 1749 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 417 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 351 times.
✓ Branch 11 taken 1338 times.
✓ Branch 12 taken 35 times.
✓ Branch 13 taken 1837 times.
✓ Branch 14 taken 19938 times.
✓ Branch 15 taken 1789 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2335 times.
✓ Branch 18 taken 20 times.
✓ Branch 19 taken 13934 times.
✓ Branch 20 taken 12 times.
✓ Branch 21 taken 8 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
46290 switch(itm.family)
11713 {
11714 case itype_liftglove:
11715 {
11716 do_liftglove(itemid,false);
11717 dowpn = -1;
11718 ret = false;
11719 break;
11720 }
11721 case itype_potion:
11722 {
11723
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11724 {
11725 return item_error();
11726 }
11727
11728 35 paymagiccost(itemid);
11729
11730
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if(itm.misc1 || itm.misc2)
11731 {
11732 35 refill_what=REFILL_ALL;
11733 35 refill_why=itemid;
11734 35 StartRefill(REFILL_ALL);
11735 35 potion_life = game->get_life();
11736 35 potion_magic = game->get_magic();
11737
11738 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
11739 //music_pause();
11740 35 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11741
2/2
✓ Branch 0 taken 6288 times.
✓ Branch 1 taken 35 times.
6323 while(refill())
11742 {
11743 6288 do_refill_waitframe();
11744 }
11745
11746 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
11747 //music_resume();
11748 35 ret = false;
11749 35 }
11750
11751 35 break;
11752 }
11753 case itype_bottle:
11754 {
11755 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11756 {
11757 return item_error();
11758 }
11759 if(itm.script!=0 && (FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
11760 return false;
11761
11762 size_t bind = game->get_bottle_slot(itm.misc1);
11763 bool paidmagic = false;
11764 if(itm.script)
11765 {
11766 paidmagic = true;
11767 paymagiccost(itemid);
11768
11769 int i = itemid;
11770 FFCore.reset_script_engine_data(ScriptType::Item, i);
11771 ZScriptVersion::RunScript(ScriptType::Item, itm.script, i);
11772 bind = game->get_bottle_slot(itm.misc1);
11773 }
11774 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
11775 if(bt)
11776 {
11777 word toFill[3] = { 0 };
11778 for(size_t q = 0; q < 3; ++q)
11779 {
11780 char c = bt->counter[q];
11781 if(c > -1)
11782 {
11783 if(bt->flags & (1<<q))
11784 {
11785 toFill[q] = (bt->amount[q]==100)
11786 ? game->get_maxcounter(c)
11787 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
11788 }
11789 else toFill[q] = bt->amount[q];
11790 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
11791 {
11792 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
11793 }
11794 }
11795 }
11796 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
11797 bool run = max > 0;
11798 if(get_qr(qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
11799 run = ((bt->counter[0] > -1 && !toFill[0]) || (bt->counter[1] > -1 && !toFill[1]) || (bt->counter[2] > -1 && !toFill[2]));
11800 else
11801 {
11802 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
11803 run = true;
11804 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
11805 run = true;
11806 }
11807 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
11808 {
11809 if(bt->flags & BTFLAG_CURESWJINX)
11810 {
11811 swordclk = 0;
11812 verifyAWpn();
11813 }
11814 if(bt->flags & BTFLAG_CUREITJINX)
11815 itemclk = 0;
11816 if(!paidmagic)
11817 paymagiccost(itemid);
11818 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11819 sfx(itm.usesound,pan(x.getInt()));
11820 for(size_t q = 0; q < 20; ++q)
11821 do_refill_waitframe();
11822 double inc = max/60.0; //1 second
11823 double xtra[3]{ 0 };
11824 for(size_t q = 0; q < 60; ++q)
11825 {
11826 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
11827 sfx(QMisc.miscsfx[sfxREFILL]);
11828 for(size_t j = 0; j < 3; ++j)
11829 {
11830 xtra[j] += inc;
11831 word f = floor(xtra[j]);
11832 xtra[j] -= f;
11833 if(toFill[j] > f)
11834 {
11835 toFill[j] -= f;
11836 game->change_counter(f,bt->counter[j]);
11837 }
11838 else if(toFill[j])
11839 {
11840 game->change_counter(toFill[j],bt->counter[j]);
11841 toFill[j] = 0;
11842 }
11843 }
11844 do_refill_waitframe();
11845 }
11846 for(size_t j = 0; j < 3; ++j)
11847 {
11848 if(toFill[j])
11849 {
11850 game->change_counter(toFill[j],bt->counter[j]);
11851 toFill[j] = 0;
11852 }
11853 }
11854 for(size_t q = 0; q < 20; ++q)
11855 do_refill_waitframe();
11856 game->set_bottle_slot(itm.misc1, bt->next_type);
11857 }
11858 }
11859
11860 dowpn = -1;
11861 ret = false;
11862 break;
11863 }
11864
11865 case itype_note:
11866 {
11867 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11868 {
11869 return item_error();
11870 }
11871 if(!msg_active && itm.misc1 > 0 && itm.misc1 < MAXMSGS)
11872 {
11873 sfx(itm.usesound);
11874 donewmsg(itm.misc1);
11875 paymagiccost(itemid);
11876 }
11877 dowpn = -1;
11878 ret = false;
11879 break;
11880 }
11881
11882 case itype_mirror:
11883 doMirror(itemid);
11884 if(Quit)
11885 return false;
11886 ret = false;
11887 break;
11888
11889 case itype_rocs:
11890 {
11891
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 23 times.
417 if(!do_jump(itemid,false)) return false;
11892 394 ret = false;
11893 }
11894 394 break;
11895
11896 case itype_letter:
11897 {
11898
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 if(current_item(itype_letter)==i_letter &&
11899
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tmpscr[currscr<128?0:1].room==rP_SHOP &&
11900
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tmpscr[currscr<128?0:1].guy &&
11901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ((currscr<128&&!(DMaps[currdmap].flags&dmfGUYCAVES))
11902
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 ||(currscr>=128&&DMaps[currdmap].flags&dmfGUYCAVES)) &&
11903 4 checkbunny(itemid)
11904 )
11905 {
11906 4 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11907
11908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(usedid != -1)
11909 4 getitem(usedid, true, true);
11910
11911 4 sfx(tmpscr[currscr<128?0:1].secretsfx);
11912 4 setupscreen();
11913 4 action=none; FFCore.setHeroAction(none);
11914 4 }
11915
11916 4 ret = false;
11917 }
11918 4 break;
11919
11920 case itype_whistle:
11921 {
11922 bool whistleflag;
11923
11924
4/4
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 351 times.
351 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11925 {
11926 12 return item_error();
11927 }
11928
11929 351 paymagiccost(itemid);
11930 351 sfx(itm.usesound);
11931
11932
4/4
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 135 times.
351 if(dir==up || dir==right)
11933 216 ++blowcnt;
11934 else
11935 135 --blowcnt;
11936
11937 351 uint32_t frames_to_wait = 0;
11938
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 345 times.
351 if (replay_is_active())
11939 {
11940 // How long an sfx takes to play (`sfx_allocated`) is not deterministic,
11941 // use a fixed number of frames in replay mode.
11942 // This has changed over time.
11943
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 128 times.
345 if (replay_version_check(0, 26))
11944 {
11945 217 frames_to_wait = 180;
11946 217 }
11947
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 46 times.
128 else if (replay_version_check(27, 31))
11948 {
11949 82 frames_to_wait = 0;
11950 82 }
11951 else
11952 {
11953 46 SAMPLE* sample = sfx_get_sample(itm.usesound);
11954 ASSERT(sample);
11955
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
46 if (sample && sample->freq)
11956 46 frames_to_wait = 60 * sample->len / sample->freq;
11957 }
11958 345 }
11959
11960 351 int sfx_count = 0;
11961
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 47481 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47487 times.
✓ Branch 6 taken 47142 times.
✓ Branch 7 taken 351 times.
47493 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < frames_to_wait))
11962 {
11963 47142 sfx_count += 1;
11964 47142 advanceframe(true);
11965
11966
1/2
✓ Branch 0 taken 47142 times.
✗ Branch 1 not taken.
47142 if(Quit)
11967 return false;
11968 }
11969
11970
9/14
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 345 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 345 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 345 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 345 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 351 times.
✓ Branch 13 taken 6 times.
351 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11971
11972
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 102 times.
351 if((whistleflag=findentrance(x,y,mfWHISTLE,get_qr(qr_PERMANENT_WHISTLE_SECRETS))))
11973 102 didstuff |= did_whistle;
11974
11975
3/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 245 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 245 times.
351 if((didstuff&did_whistle && itm.flags&ITEM_FLAG1) || currscr>=128)
11976 106 return false;
11977
11978
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 239 times.
245 if(itm.flags&ITEM_FLAG1) didstuff |= did_whistle;
11979
11980
4/4
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 212 times.
245 if((tmpscr->flags&fWHISTLE) || (tmpscr->flags7 & fWHISTLEWATER)
11981
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 || (tmpscr->flags7&fWHISTLEPAL))
11982 {
11983 33 whistleclk=0; // signal to start drying lake or doing other stuff
11984 33 }
11985 else
11986 {
11987 212 int32_t where = itm.misc1;
11988
11989
1/2
✓ Branch 0 taken 212 times.
✗ Branch 1 not taken.
212 if(where>right) where=dir^1;
11990
11991
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 68 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 138 times.
350 if(((DMaps[currdmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[currdmap].flags&dmfWHIRLWINDRET) &&
11992
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
144 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
11993
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 138 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 138 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 138 times.
✗ Branch 11 not taken.
276 Lwpns.add(new weapon((zfix)(where==left?240_zf:where==right?0_zf:x),
11994
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 138 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 138 times.
✗ Branch 9 not taken.
138 (zfix)(where==down?0_zf:where==up?160_zf:y),
11995
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
138 (zfix)0,
11996 wWind,
11997 0, //type
11998 0,
11999 138 where,
12000
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
138 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
12001
12002 206 whistleitem=itemid;
12003 }
12004
12005 239 ret = false;
12006 }
12007 239 break;
12008
12009 case itype_bomb:
12010 {
12011 //Remote detonation
12012
3/4
✓ Branch 0 taken 1338 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1334 times.
1338 if(Lwpns.idCount(wLitBomb) >= zc_max(itm.misc2,1))
12013 {
12014 4 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
12015
12016
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 while(Lwpns.idCount(wLitBomb) && ew->misc == 0)
12017 {
12018 //If this ever needs a version check, in the future. -z
12019 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 ) )
12020 {
12021 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
12022 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
12023 }
12024 ew->misc=50;
12025 ew->clk=ew->misc-3;
12026 ew->id=wBomb;
12027 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
12028 }
12029
12030 4 deselectbombs(false);
12031 4 return false;
12032 }
12033
12034
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1317 times.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
1334 if((itm.flags & ITEM_FLAG4) && lift_wpn)
12035 {
12036 do_liftglove(-1,false); //Throw the already-held weapon
12037 return false;
12038 }
12039
2/4
✓ Branch 0 taken 1334 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1334 times.
1334 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12040 {
12041 return item_error();
12042 }
12043
12044 1334 paymagiccost(itemid);
12045
12046
1/2
✓ Branch 0 taken 1334 times.
✗ Branch 1 not taken.
1334 if(itm.misc1>0) // If not remote bombs
12047 1334 deselectbombs(false);
12048
12049
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 954 times.
1334 if(isdungeon())
12050 {
12051
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 918 times.
954 wy=zc_max(wy,16);
12052 954 }
12053
12054
4/8
✓ Branch 0 taken 1334 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1334 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1334 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1334 times.
✗ Branch 7 not taken.
2668 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitBomb,itm.fam_type,
12055
2/4
✓ Branch 0 taken 1334 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1334 times.
✗ Branch 3 not taken.
1334 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true);
12056 1334 bool lifted = false;
12057
2/2
✓ Branch 0 taken 1317 times.
✓ Branch 1 taken 17 times.
1334 if(itm.flags & ITEM_FLAG4)
12058 {
12059 17 auto liftid = current_item_id(itype_liftglove);
12060 17 itemdata const& glove = itemsbuf[liftid];
12061
3/6
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
17 if(liftid > -1 && (!itm.misc4 || itm.misc4 <= glove.fam_type))
12062 {
12063 17 lift(wpn,itm.misc5,itm.misc6);
12064 17 set_liftflags(liftid);
12065 17 lifted = true;
12066 17 }
12067 17 }
12068
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1317 times.
1334 if(!lifted)
12069 {
12070 1317 Lwpns.add(wpn);
12071 1317 sfx(WAV_PLACE,pan(wx));
12072 1317 }
12073 }
12074 1334 break;
12075
12076 case itype_sbomb:
12077 {
12078 //Remote detonation
12079
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 if(Lwpns.idCount(wLitSBomb) >= zc_max(itm.misc2,1))
12080 {
12081 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
12082
12083 while(Lwpns.idCount(wLitSBomb) && ew->misc == 0)
12084 {
12085 ew->misc=50;
12086 ew->clk=ew->misc-3;
12087 ew->id=wSBomb;
12088 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
12089 }
12090
12091 deselectbombs(true);
12092 return false;
12093 }
12094
12095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if((itm.flags & ITEM_FLAG4) && lift_wpn)
12096 {
12097 do_liftglove(-1,false); //Throw the already-held weapon
12098 return false;
12099 }
12100
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12101 {
12102 return item_error();
12103 }
12104
12105 35 paymagiccost(itemid);
12106
12107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(itm.misc1>0) // If not remote bombs
12108 35 deselectbombs(true);
12109
12110
6/12
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 35 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 35 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 35 times.
✗ Branch 11 not taken.
35 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitSBomb,itm.fam_type,itm.power*game->get_hero_dmgmult(),dir, itemid,getUID(),false,false,true);
12111 35 bool lifted = false;
12112
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(itm.flags & ITEM_FLAG4)
12113 {
12114 auto liftid = current_item_id(itype_liftglove);
12115 itemdata const& glove = itemsbuf[liftid];
12116 if(liftid > -1 && (!itm.misc4 || itm.misc4 <= glove.fam_type))
12117 {
12118 lift(wpn,itm.misc5,itm.misc6);
12119 set_liftflags(liftid);
12120 lifted = true;
12121 }
12122 }
12123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!lifted)
12124 {
12125 35 Lwpns.add(wpn);
12126 35 sfx(WAV_PLACE,pan(wx));
12127 35 }
12128 }
12129 35 break;
12130
12131 case itype_wand:
12132 {
12133
2/2
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 1397 times.
1837 if(Lwpns.idCount(wMagic))
12134 {
12135 440 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
12136 440 return false;
12137 }
12138
12139 1397 int32_t bookid = current_item_id(itype_book);
12140
3/4
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 716 times.
1397 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
12141
12142
4/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 1224 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 139 times.
1397 if(!(itm.flags&ITEM_FLAG1) && !paybook) //Can the wand shoot without the book?
12143 {
12144 139 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
12145 139 return false;
12146 }
12147
12148
4/6
✓ Branch 0 taken 1258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1258 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1255 times.
✓ Branch 5 taken 3 times.
1258 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
12149 {
12150 3 return item_error();
12151 }
12152
12153
2/2
✓ Branch 0 taken 1251 times.
✓ Branch 1 taken 4 times.
1255 if(Lwpns.idCount(wBeam))
12154 4 Lwpns.del(Lwpns.idFirst(wBeam));
12155
12156 int32_t type, pow;
12157
2/2
✓ Branch 0 taken 533 times.
✓ Branch 1 taken 722 times.
1255 if ( get_qr(qr_BROKENBOOKCOST) )
12158 {
12159
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 413 times.
533 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
12160
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 413 times.
533 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
12161 533 }
12162 else
12163 {
12164
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 419 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
722 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
12165
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 419 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
722 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
12166 }
12167
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2510 times.
✓ Branch 4 taken 1255 times.
✓ Branch 5 taken 1255 times.
2510 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
12168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
2510 if(dir!=(i^1))
12169 {
12170
5/10
✓ Branch 0 taken 1255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1255 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1255 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1255 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1255 times.
✗ Branch 9 not taken.
1255 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
12171
2/2
✓ Branch 0 taken 539 times.
✓ Branch 1 taken 716 times.
1255 if(paybook)
12172 716 magic->linkedItem = bookid;
12173 //magic->dir = this->dir; //Save player dir for special weapons.
12174 1255 Lwpns.add(magic);
12175 1255 }
12176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
1255 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
12177 1255 paymagiccost(itemid);
12178 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
12179
12180
2/2
✓ Branch 0 taken 539 times.
✓ Branch 1 taken 716 times.
1255 if(paybook)
12181 716 paymagiccost(current_item_id(itype_book));
12182
12183
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 539 times.
1255 if(bookid != -1)
12184 {
12185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if (( itemsbuf[bookid].flags & ITEM_FLAG4 ))
12186 {
12187 sfx(itemsbuf[bookid].misc2,pan(wx));
12188 }
12189 else
12190 {
12191 716 sfx(itm.usesound,pan(wx));
12192 }
12193 716 }
12194 else
12195 539 sfx(itm.usesound,pan(wx));
12196 }
12197 /*
12198 // Fireball Wand
12199 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
12200 switch (dir)
12201 {
12202 case up:
12203 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
12204 Lwpns.spr(Lwpns.Count()-1)->dir=up;
12205 break;
12206 case down:
12207 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
12208 Lwpns.spr(Lwpns.Count()-1)->dir=down;
12209 break;
12210 case left:
12211 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
12212 Lwpns.spr(Lwpns.Count()-1)->dir=left;
12213 break;
12214 case right:
12215 Lwpns.spr(Lwpns.Count()-1)->angle=0;
12216 Lwpns.spr(Lwpns.Count()-1)->dir=right;
12217 break;
12218 }
12219 Lwpns.spr(Lwpns.Count()-1)->clk=16;
12220 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
12221 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
12222 */
12223 1255 break;
12224
12225 case itype_sword:
12226 {
12227
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 19938 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19938 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
12228 {
12229 return item_error();
12230 }
12231
12232
4/4
✓ Branch 0 taken 4249 times.
✓ Branch 1 taken 15689 times.
✓ Branch 2 taken 4249 times.
✓ Branch 3 taken 15689 times.
19938 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
12233 {
12234 4249 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12235 4249 return false;
12236 }
12237
12238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15689 times.
15689 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
12239 15689 paymagiccost(itemid);
12240 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12241 float temppower;
12242
12243
1/2
✓ Branch 0 taken 15689 times.
✗ Branch 1 not taken.
15689 if(itm.flags & ITEM_FLAG2)
12244 {
12245 15689 temppower=game->get_hero_dmgmult()*itm.power;
12246 15689 temppower=temppower*itm.misc2;
12247 15689 temppower=temppower/100;
12248 15689 }
12249 else
12250 {
12251 temppower = game->get_hero_dmgmult()*itm.misc2;
12252 }
12253
12254 //Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID()));
12255 //Add weapon script to sword beams.
12256
5/10
✓ Branch 0 taken 15689 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15689 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15689 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15689 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15689 times.
✗ Branch 9 not taken.
15689 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID(),false,false,true));
12257 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //the pointer to this beam
12258 //w->weaponscript = itm.weaponscript;
12259 //w->canrunscript = 0;
12260 15689 sfx(WAV_BEAM,pan(wx));
12261 }
12262 15689 break;
12263
12264 case itype_candle:
12265 {
12266 1789 int32_t countid = itemid;
12267
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 1714 times.
1789 if(get_qr(qr_CANDLES_SHARED_LIMIT))
12268 1714 countid = -itype_candle;
12269
5/6
✓ Branch 0 taken 1393 times.
✓ Branch 1 taken 396 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 396 times.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 1770 times.
1789 if(itm.flags&ITEM_FLAG1 && usecounts[countid] >= zc_max(1, itm.misc3))
12270 {
12271 19 return false;
12272 }
12273
12274
3/4
✓ Branch 0 taken 1770 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 1674 times.
1770 if(Lwpns.idCount(wFire) >= (itm.misc2 < 1 ? 2 : itm.misc2))
12275 {
12276 96 return false;
12277 }
12278
12279
3/4
✓ Branch 0 taken 1674 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 1665 times.
1674 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12280 {
12281 9 return item_error();
12282 }
12283
12284 1665 paymagiccost(itemid);
12285
12286
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 369 times.
1665 if(itm.flags&ITEM_FLAG1) ++usecounts[countid];
12287
12288
4/8
✓ Branch 0 taken 1665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1665 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1665 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1665 times.
✗ Branch 7 not taken.
3330 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
12289 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
12290 1665 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
12291
2/4
✓ Branch 0 taken 1665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1665 times.
✗ Branch 3 not taken.
1665 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12292 1665 sfx(itm.usesound,pan(wx));
12293 1665 attack=wFire;
12294 }
12295 1665 break;
12296
12297 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
12298 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
12299 {
12300 int32_t wtype = wScript1 + (itm.family-itype_script1);
12301 if(Lwpns.idCount(wtype))
12302 return false;
12303
12304 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12305 {
12306 return item_error();
12307 }
12308
12309 if(!get_qr(qr_CUSTOMWEAPON_IGNORE_COST))
12310 paymagiccost(itemid);
12311
12312 zfix wpnstep = zfix(itm.misc1)/100;
12313 if(replay_version_check(0,30))
12314 wpnstep = itm.misc1/100;
12315
12316 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
12317 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = wpnstep;
12318 sfx(itm.usesound,pan(wx));
12319 }
12320 break;
12321
12322 case itype_icerod:
12323 {
12324 if(Lwpns.idCount(wIce))
12325 return false;
12326
12327 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12328 {
12329 return item_error();
12330 }
12331
12332 if(!get_qr(qr_CUSTOMWEAPON_IGNORE_COST))
12333 paymagiccost(itemid);
12334
12335 zfix wpnstep = zfix(itm.misc1)/100;
12336 if(replay_version_check(0,30))
12337 wpnstep = itm.misc1/100;
12338
12339 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
12340 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = wpnstep;
12341 sfx(itm.usesound,pan(wx));
12342 }
12343 break;
12344
12345 case itype_arrow:
12346 {
12347
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2335 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 2246 times.
2335 if(Lwpns.idCount(wArrow) >= (itm.misc2 < 1 ? 1 : itm.misc2))
12348 89 return false;
12349
12350
3/4
✓ Branch 0 taken 2246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 2232 times.
2246 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12351 {
12352 14 return item_error();
12353 }
12354
12355 2232 paymagiccost(itemid);
12356
12357
6/12
✓ Branch 0 taken 2232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2232 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2232 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2232 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2232 times.
✗ Branch 11 not taken.
2232 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
12358 2232 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
12359 2232 sfx(itm.usesound,pan(wx));
12360 }
12361 2232 break;
12362
12363 case itype_bait:
12364 {
12365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
12366 return false;
12367
12368
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 3 times.
20 if(!checkbunny(itemid))
12369 3 return item_error();
12370
12371
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
33 bool grumble = (tmpscr->room==rGRUMBLE && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)));
12372
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 bool checkcost = grumble || !(itm.flags & ITEM_FLAG4);
12373
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 bool paycost = grumble || !(itm.flags & (ITEM_FLAG4|ITEM_FLAG5));
12374
12375
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17 if(!grumble && (itm.flags & ITEM_FLAG2))
12376 return item_error(); //Only usable for grumble rooms
12377
12378
2/4
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
17 if(checkcost && !checkmagiccost(itemid))
12379 return item_error();
12380
12381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(paycost)
12382 17 paymagiccost(itemid);
12383 17 sfx(itm.usesound,pan(wx));
12384
12385
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 if(grumble)
12386 {
12387
4/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
16 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,itemid,ipDUMMY+ipFADE,0));
12388 16 fadeclk=66;
12389 16 dismissmsg();
12390 16 clear_bitmap(pricesdisplaybuf);
12391 16 set_clip_state(pricesdisplaybuf, 1);
12392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
12393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itm.flags & ITEM_FLAG3)) //"Don't remove when feeding" flag
12394 {
12395 16 removeItemsOfFamily(game,itemsbuf,itype_bait);
12396 16 verifyBothWeapons();
12397 16 }
12398 16 sfx(tmpscr->secretsfx);
12399 16 return false;
12400 }
12401
12402
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
12403 1 break;
12404 }
12405
12406 case itype_brang:
12407 {
12408
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 13607 times.
13934 if(Lwpns.idCount(wBrang) > itm.misc2)
12409 327 return false;
12410
12411
2/4
✓ Branch 0 taken 13607 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13607 times.
13607 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12412 {
12413 return item_error();
12414 }
12415
12416 13607 paymagiccost(itemid);
12417 13607 current_item_power(itype_brang);
12418
6/12
✓ Branch 0 taken 13607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13607 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13607 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13607 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13607 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13607 times.
✗ Branch 11 not taken.
13607 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
12419 }
12420 13607 break;
12421
12422 case itype_hookshot:
12423 case itype_switchhook:
12424 {
12425
3/4
✓ Branch 0 taken 2483 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2483 times.
2484 if(inlikelike || Lwpns.idCount(wHookshot))
12426 1 return false;
12427
12428
2/4
✓ Branch 0 taken 2483 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2483 times.
2483 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12429 {
12430 return item_error();
12431 }
12432 2483 bool sw = itm.family == itype_switchhook;
12433
12434
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2481 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2483 if(sw && (itm.flags&ITEM_FLAG8))
12435 switchhook_cost_item = itemid;
12436 2483 else paymagiccost(itemid);
12437
12438 2483 bool use_hookshot=true;
12439 2483 bool hit_hs = false, hit_solid = false, insta_switch = false;
12440
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 2384 times.
2483 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
12441 2483 int32_t cpos = -1, ffcpos = -1;
12442
4/4
✓ Branch 0 taken 2449 times.
✓ Branch 1 taken 5758 times.
✓ Branch 2 taken 5724 times.
✓ Branch 3 taken 2483 times.
8207 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
12443 {
12444
2/2
✓ Branch 0 taken 4719 times.
✓ Branch 1 taken 1005 times.
5724 if(dir==up)
12445 {
12446
2/2
✓ Branch 0 taken 981 times.
✓ Branch 1 taken 24 times.
1005 if(check_hshot(i,x+2,y-7,sw, &cpos, &ffcpos))
12447 24 hit_hs = true;
12448 1005 }
12449
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 3673 times.
4719 else if(dir==down)
12450 {
12451
1/2
✓ Branch 0 taken 1046 times.
✗ Branch 1 not taken.
1046 if(check_hshot(i,x+12,y+23,sw, &cpos, &ffcpos))
12452 hit_hs = true;
12453 1046 }
12454
2/2
✓ Branch 0 taken 1822 times.
✓ Branch 1 taken 1851 times.
3673 else if(dir==left)
12455 {
12456
2/2
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 9 times.
1822 if(check_hshot(i,x-7,y+12,sw, &cpos, &ffcpos))
12457 9 hit_hs = true;
12458 1822 }
12459
1/2
✓ Branch 0 taken 1851 times.
✗ Branch 1 not taken.
1851 else if(dir==right)
12460 {
12461
2/2
✓ Branch 0 taken 1848 times.
✓ Branch 1 taken 3 times.
1851 if(check_hshot(i,x+23,y+12,sw, &cpos, &ffcpos))
12462 3 hit_hs = true;
12463 1851 }
12464 //Diagonal Hookshot (6)
12465 else if(dir==r_down)
12466 {
12467 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
12468 hit_hs = true;
12469 }
12470 else if(dir==l_down)
12471 {
12472 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
12473 hit_hs = true;
12474 }
12475 else if(dir==r_up)
12476 {
12477 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
12478 hit_hs = true;
12479 }
12480 else if(dir==l_up)
12481 {
12482 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
12483 hit_hs = true;
12484 }
12485 5724 }
12486
8/10
✓ Branch 0 taken 2067 times.
✓ Branch 1 taken 416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 416 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 416 times.
✓ Branch 6 taken 362 times.
✓ Branch 7 taken 54 times.
✓ Branch 8 taken 2454 times.
✓ Branch 9 taken 29 times.
2483 if(dir==up && _walkflag(x+2,y+4,1,SWITCHBLOCK_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
12487 29 hit_solid = true;
12488
2/2
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 36 times.
2483 if(hit_hs)
12489 {
12490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(sw)
12491 insta_switch = true; //switch immediately
12492 36 else use_hookshot = false; //No hooking against grabbable
12493 36 }
12494
3/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 2454 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
2483 if(hit_solid && !insta_switch)
12495 29 use_hookshot = false;
12496
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2433 times.
2483 if(use_hookshot)
12497 {
12498 2433 int32_t hookitem = itm.fam_type;
12499 2433 int32_t hookpower = itm.power;
12500 2433 byte allow_diagonal = (itm.flags & ITEM_FLAG2) ? 1 : 0;
12501
12502
1/2
✓ Branch 0 taken 2433 times.
✗ Branch 1 not taken.
2433 if(!Lwpns.has_space())
12503 {
12504 Lwpns.del(0);
12505 }
12506
12507
1/2
✓ Branch 0 taken 2433 times.
✗ Branch 1 not taken.
2433 if(!Lwpns.has_space(2))
12508 {
12509 Lwpns.del(0);
12510 }
12511
12512
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 378 times.
✓ Branch 2 taken 440 times.
✓ Branch 3 taken 783 times.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
2433 switch(dir)
12513 {
12514 case up:
12515 {
12516 378 hookshot_used=true;
12517 378 hs_switcher = sw;
12518
4/8
✓ Branch 0 taken 378 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 378 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 378 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 378 times.
✗ Branch 7 not taken.
756 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12519
2/4
✓ Branch 0 taken 378 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 378 times.
✗ Branch 3 not taken.
378 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12520 378 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12521
5/10
✓ Branch 0 taken 378 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 378 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 378 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 378 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 378 times.
✗ Branch 9 not taken.
756 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
12522
2/4
✓ Branch 0 taken 378 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 378 times.
✗ Branch 3 not taken.
378 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12523 378 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12524 378 hs_startx=wx;
12525 378 hs_starty=wy-4;
12526 }
12527 378 break;
12528
12529 case down:
12530 {
12531 440 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
12532 440 hookshot_used=true;
12533 440 hs_switcher = sw;
12534
5/10
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 440 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 440 times.
✗ Branch 9 not taken.
880 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
12535
2/4
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
440 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12536 440 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12537
5/10
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 440 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 440 times.
✗ Branch 9 not taken.
880 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
12538
2/4
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
440 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12539 440 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12540 440 hs_startx=wx;
12541 440 hs_starty=wy;
12542 }
12543 440 break;
12544
12545 case left:
12546 {
12547 783 hookshot_used=true;
12548 783 hs_switcher = sw;
12549
4/8
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 783 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 783 times.
✗ Branch 7 not taken.
1566 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12550
2/4
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
783 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12551 783 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12552
4/8
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 783 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 783 times.
✗ Branch 7 not taken.
1566 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12553
2/4
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
783 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12554 783 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12555 783 hs_startx=wx-4;
12556 783 hs_starty=wy;
12557 }
12558 783 break;
12559
12560 case right:
12561 {
12562 832 hookshot_used=true;
12563 832 hs_switcher = sw;
12564
4/8
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 832 times.
✗ Branch 7 not taken.
1664 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12565
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
832 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12566 832 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12567
4/8
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 832 times.
✗ Branch 7 not taken.
1664 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12568
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
832 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12569 832 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12570 832 hs_startx=wx+4;
12571 832 hs_starty=wy;
12572 }
12573 832 break;
12574 //Diagonal Hookshot (7)
12575 case r_down:
12576 {
12577 hookshot_used=true;
12578 hs_switcher = sw;
12579 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
12580 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
12581 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12582 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12583 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
12584 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12585 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12586 hs_startx=wx+4;
12587 hs_starty=wy;
12588 }
12589 break;
12590
12591 case r_up:
12592 {
12593 hookshot_used=true;
12594 hs_switcher = sw;
12595 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12596 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12597 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12598 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12599 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12600 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12601 hs_startx=wx+4;
12602 hs_starty=wy;
12603 }
12604 break;
12605
12606 case l_down:
12607 {
12608 hookshot_used=true;
12609 hs_switcher = sw;
12610 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
12611 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
12612 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12613 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12614 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
12615 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12616 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12617 hs_startx=wx+4;
12618 hs_starty=wy;
12619 }
12620 break;
12621
12622 case l_up:
12623 {
12624 hookshot_used=true;
12625 hs_switcher = sw;
12626 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12627 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12628 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12629 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12630 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12631 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12632 hs_startx=wx+4;
12633 hs_starty=wy;
12634 }
12635 break;
12636 }
12637 2433 hookshot_frozen=true;
12638 2433 }
12639
1/2
✓ Branch 0 taken 2483 times.
✗ Branch 1 not taken.
2483 if(insta_switch)
12640 {
12641 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
12642 if (cpos > -1) hooked_combopos = cpos;
12643 if (ffcpos > -1)
12644 {
12645 switching_object = &(tmpscr->ffcs[ffcpos]);
12646 switching_object->switch_hooked = true;
12647 }
12648 w->misc=2;
12649 w->step=0;
12650 doSwitchHook(itm.misc5);
12651 if(itm.usesound2)
12652 sfx(itm.usesound2,pan(int32_t(x)));
12653 else if(QMisc.miscsfx[sfxSWITCHED])
12654 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
12655 stop_sfx(itm.usesound);
12656 }
12657 }
12658 2483 break;
12659
12660 case itype_divinefire:
12661
3/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
12 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(this) || getOnSideviewLadder() || IsSideSwim())))
12662 return false;
12663
12664
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12665 {
12666 return item_error();
12667 }
12668
12669 12 paymagiccost(itemid);
12670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12671 12 else {action=casting; FFCore.setHeroAction(casting);}
12672 12 magicitem=itemid;
12673 12 break;
12674
12675 case itype_divineescape:
12676
3/12
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(this) || getOnSideviewLadder() || IsSideSwim())))
12677 return false;
12678
12679
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12680 {
12681 return item_error();
12682 }
12683
12684 8 paymagiccost(itemid);
12685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12686 8 else {action=casting; FFCore.setHeroAction(casting);}
12687 8 magicitem=itemid;
12688 8 break;
12689
12690 case itype_divineprotection:
12691 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(this) || getOnSideviewLadder() || IsSideSwim())))
12692 return false;
12693
12694 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12695 {
12696 return item_error();
12697 }
12698
12699 paymagiccost(itemid);
12700 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12701 else {action=casting; FFCore.setHeroAction(casting);}
12702 magicitem=itemid;
12703 break;
12704
12705 case itype_cbyrna:
12706 {
12707 //Beams already deployed
12708
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(Lwpns.idCount(wCByrna))
12709 {
12710 2 stopCaneOfByrna();
12711 2 return false;
12712 }
12713
12714
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12715 {
12716 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
12717 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
12718 return false;
12719 }
12720
12721 2 paymagiccost(itemid);
12722 2 last_cane_of_byrna_item_id = itemid;
12723 //zprint("itm.misc3: %d\n", itm.misc3);
12724
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for(int32_t i=0; i<itm.misc3; i++)
12725 {
12726 //byrna weapons are added here
12727 //space them apart
12728 //zprint("Added byrna weapon %d.\n", i);
12729 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
12730 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
12731
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12732 //Lwpns.add(new weapon((zfix)wx+cos(2 * PI / (i+1)),(zfix)wy+sin(2 * PI / (i+1)),(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12733 //wx += cos(2 * PI / (itm.misc3-i));
12734 //wy += sin(2 * PI / (itm.misc3-i));
12735 2 }
12736
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(Lwpns.idCount(wCByrna)))
12737 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
12738 }
12739 2 break;
12740
12741 case itype_clock:
12742 {
12743 ret = false;
12744 if(!(itm.flags & ITEM_FLAG1))
12745 break; //Passive clock, don't use
12746 if((itm.flags & ITEM_FLAG2) && watch) //"Can't activate while clock active"
12747 break;
12748 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
12749 {
12750 return item_error();
12751 }
12752
12753 paymagiccost(itemid);
12754
12755 setClock(watch=true);
12756
12757 for(int32_t i=0; i<eMAXGUYS; i++)
12758 clock_zoras[i]=0;
12759
12760 clockclk=itm.misc1;
12761 sfx(itm.usesound);
12762 break;
12763 }
12764 case itype_killem:
12765 {
12766 ret = false;
12767 if(!(itm.flags & ITEM_FLAG1))
12768 break; //Passive killemall, don't use
12769
12770 if(!(checkbunny(itemid) && checkmagiccost(itemid))
12771 || !can_kill_em_all()) //No enemies onscreen
12772 {
12773 return item_error();
12774 }
12775
12776 paymagiccost(itemid);
12777
12778 kill_em_all();
12779 sfx(itm.usesound);
12780 break;
12781 }
12782 case itype_refill:
12783 {
12784 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12785 {
12786 return item_error();
12787 }
12788
12789 bool did_something = false;
12790
12791 if(itm.flags & ITEM_FLAG1) //Cure sword jinx
12792 {
12793 if(swordclk)
12794 did_something = true;
12795 swordclk = 0;
12796 verifyAWpn();
12797 }
12798 for(auto q = 0; q < 5; ++q)
12799 {
12800 auto ctr = itm.misc(q);
12801 if(unsigned(ctr) >= MAX_COUNTERS)
12802 continue;
12803 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
12804 if(!amnt) continue;
12805 bool gradual = itm.flags & ITEM_FLAG2;
12806 if(amnt > 0)
12807 {
12808 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
12809 {
12810 //Can't *do* anything... skip
12811 continue;
12812 }
12813 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
12814 {
12815 //Can't do anything unless affecting dcounter
12816 gradual = true;
12817 }
12818 }
12819 else //Negative
12820 {
12821 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
12822 {
12823 //Can't *do* anything... skip
12824 continue;
12825 }
12826 if(game->get_counter(ctr) <= 0)
12827 {
12828 //Can't do anything unless affecting dcounter
12829 gradual = true;
12830 }
12831 }
12832 did_something = true;
12833 if(gradual) //Gradual
12834 {
12835 game->change_dcounter(amnt, ctr);
12836 }
12837 else
12838 {
12839 game->change_counter(amnt, ctr);
12840 }
12841 }
12842 if(!did_something)
12843 {
12844 return item_error();
12845 }
12846 paymagiccost(itemid);
12847 sfx(itm.usesound);
12848 ret = false;
12849 break;
12850 }
12851
12852 default:
12853 1749 ret = false;
12854 1749 }
12855
12856
2/2
✓ Branch 0 taken 40709 times.
✓ Branch 1 taken 35 times.
40744 if(itm.flags & ITEM_DOWNGRADE)
12857 {
12858 35 game->set_item(itemid,false);
12859
12860 // Maybe Item Override has allowed the same item in both slots?
12861
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Bwpn == itemid)
12862 {
12863 Bwpn = -1;
12864 game->forced_bwpn = -1;
12865 verifyBWpn();
12866 }
12867
12868
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Awpn == itemid)
12869 {
12870 Awpn = -1;
12871 game->forced_awpn = -1;
12872 verifyAWpn();
12873 }
12874
12875
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Xwpn == itemid)
12876 {
12877 Xwpn = -1;
12878 game->forced_xwpn = -1;
12879 verifyXWpn();
12880 }
12881
12882
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Ywpn == itemid)
12883 {
12884 Ywpn = -1;
12885 game->forced_ywpn = -1;
12886 verifyYWpn();
12887 }
12888 35 }
12889
12890 40744 return ret;
12891 46412 }
12892
12893
12894 1856272 bool HeroClass::doattack()
12895 {
12896
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1856255 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
1856272 if(lift_wpn && (liftflags & LIFTFL_DIS_ITEMS))
12897 17 return false;
12898 //int32_t s = BSZ ? 0 : 11;
12899 1856255 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
12900
12901
4/4
✓ Branch 0 taken 469087 times.
✓ Branch 1 taken 1387168 times.
✓ Branch 2 taken 468943 times.
✓ Branch 3 taken 144 times.
1856255 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
12902
3/4
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 1856111 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
1856255 if(attack==wBugNet && bugnetid!=-1)
12903 {
12904
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 138 times.
144 if(++attackclk >= NET_CLK_TOTAL)
12905 6 return false;
12906
12907 138 return true;
12908 }
12909
12910 // Abort attack if attackclk has run out and:
12911 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
12912 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
12913
12914
6/6
✓ Branch 0 taken 182724 times.
✓ Branch 1 taken 1673387 times.
✓ Branch 2 taken 147240 times.
✓ Branch 3 taken 35484 times.
✓ Branch 4 taken 51479 times.
✓ Branch 5 taken 17729 times.
1925319 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
12915
12/12
✓ Branch 0 taken 134819 times.
✓ Branch 1 taken 12421 times.
✓ Branch 2 taken 66153 times.
✓ Branch 3 taken 68666 times.
✓ Branch 4 taken 79291 times.
✓ Branch 5 taken 67949 times.
✓ Branch 6 taken 78032 times.
✓ Branch 7 taken 1259 times.
✓ Branch 8 taken 66113 times.
✓ Branch 9 taken 3095 times.
✓ Branch 10 taken 50945 times.
✓ Branch 11 taken 15168 times.
147240 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
12916 {
12917 95761 tapping=false;
12918 95761 return false;
12919 }
12920
12921
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 1758055 times.
1760350 if(attackclk>29)
12922 {
12923 2295 tapping=false;
12924 2295 return false;
12925 }
12926
12927
4/4
✓ Branch 0 taken 451542 times.
✓ Branch 1 taken 1306513 times.
✓ Branch 2 taken 428640 times.
✓ Branch 3 taken 22902 times.
1758055 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
12928
4/4
✓ Branch 0 taken 451542 times.
✓ Branch 1 taken 1306513 times.
✓ Branch 2 taken 451512 times.
✓ Branch 3 taken 30 times.
1758055 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
12929 // An attack can be "walked out-of" after 8 frames, unless it's:
12930 // * a sword stab
12931 // * a hammer pound
12932 // * a wand thrust
12933 // * a candle thrust
12934 // * a cane thrust
12935 // In which case it should continue.
12936
8/8
✓ Branch 0 taken 68867 times.
✓ Branch 1 taken 1689188 times.
✓ Branch 2 taken 197207 times.
✓ Branch 3 taken 128340 times.
✓ Branch 4 taken 1614222 times.
✓ Branch 5 taken 203306 times.
✓ Branch 6 taken 360455 times.
✓ Branch 7 taken 1253767 times.
2053460 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
12937
5/6
✓ Branch 0 taken 296093 times.
✓ Branch 1 taken 64362 times.
✓ Branch 2 taken 21921 times.
✓ Branch 3 taken 274172 times.
✓ Branch 4 taken 21921 times.
✗ Branch 5 not taken.
360455 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
12938
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 274142 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
296093 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
12939
2/2
✓ Branch 0 taken 295405 times.
✓ Branch 1 taken 21263 times.
274172 && (attack != wBugNet) && attackclk>7))
12940 {
12941
8/8
✓ Branch 0 taken 93459 times.
✓ Branch 1 taken 4739 times.
✓ Branch 2 taken 88916 times.
✓ Branch 3 taken 4543 times.
✓ Branch 4 taken 83732 times.
✓ Branch 5 taken 5184 times.
✓ Branch 6 taken 5625 times.
✓ Branch 7 taken 78107 times.
492612 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
12942 {
12943 20091 lstep = s;
12944 20091 return false;
12945 }
12946 78107 }
12947
12948
2/2
✓ Branch 0 taken 40923 times.
✓ Branch 1 taken 1601833 times.
1642756 if(charging==0)
12949 {
12950 1601833 lstep=0;
12951 1601833 }
12952
12953 // Work out the sword charge-up delay
12954 1642756 int32_t magiccharge = 192, normalcharge = 64;
12955 1642756 int32_t itemid = current_item_id(itype_chargering);
12956
12957
2/2
✓ Branch 0 taken 1593092 times.
✓ Branch 1 taken 49664 times.
1642756 if(itemid>=0)
12958 {
12959 49664 normalcharge = itemsbuf[itemid].misc1;
12960 49664 magiccharge = itemsbuf[itemid].misc2;
12961 49664 }
12962
12963 1642756 int scrollid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12964 1642756 int scroll2id = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12965
12966 1642756 bool doCharge=true;
12967
3/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 1642606 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 150 times.
1642756 if(z!=0 && fakez != 0)
12968 doCharge=false;
12969
2/2
✓ Branch 0 taken 1253767 times.
✓ Branch 1 taken 388989 times.
1642756 if(attack==wSword)
12970 {
12971
4/4
✓ Branch 0 taken 34916 times.
✓ Branch 1 taken 1218851 times.
✓ Branch 2 taken 613 times.
✓ Branch 3 taken 34303 times.
1253767 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12972 1219464 doCharge=false;
12973
2/2
✓ Branch 0 taken 10820 times.
✓ Branch 1 taken 23483 times.
34303 else if(charging<=normalcharge)
12974 {
12975
3/6
✓ Branch 0 taken 23483 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23483 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23483 times.
✗ Branch 5 not taken.
23483 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12976 doCharge=false;
12977 23483 }
12978 1253767 }
12979
2/2
✓ Branch 0 taken 64362 times.
✓ Branch 1 taken 324627 times.
388989 else if(attack==wHammer)
12980 {
12981
4/4
✓ Branch 0 taken 2186 times.
✓ Branch 1 taken 62176 times.
✓ Branch 2 taken 1943 times.
✓ Branch 3 taken 243 times.
64362 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
12982 64119 doCharge=false;
12983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243 times.
243 else if(charging<=normalcharge)
12984 {
12985
4/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
243 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12986 227 doCharge=false;
12987 243 }
12988 64362 }
12989 else
12990 324627 doCharge=false;
12991
12992 // charging up weapon...
12993
2/2
✓ Branch 0 taken 34319 times.
✓ Branch 1 taken 1608437 times.
1642756 if(doCharge)
12994 {
12995 // Increase charging while holding down button.
12996
3/4
✓ Branch 0 taken 34319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2543 times.
✓ Branch 3 taken 31776 times.
34319 if(spins==0 && charging<magiccharge)
12997 31776 charging++;
12998
12999 // Once a charging threshold is reached, play the sound.
13000
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 34145 times.
34319 if(charging==normalcharge)
13001 {
13002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(!(itemsbuf[scrollid].flags&ITEM_FLAG1))
13003 174 paymagiccost(scrollid);
13004 174 sfx(itemsbuf[scrollid].usesound2,pan(x.getInt()));
13005 174 }
13006
2/2
✓ Branch 0 taken 31708 times.
✓ Branch 1 taken 2437 times.
34145 else if(charging==magiccharge)
13007 {
13008
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2434 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
2437 if(scroll2id>-1 && checkbunny(scroll2id) && checkmagiccost(scroll2id))
13009 {
13010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!(itemsbuf[scroll2id].flags&ITEM_FLAG1))
13011 3 paymagiccost(scroll2id);
13012 3 charging++; // charging>magiccharge signifies a successful supercharge.
13013 3 sfx(itemsbuf[scroll2id].usesound2,pan(x.getInt()));
13014 3 }
13015 2437 }
13016 34319 }
13017
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1608407 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
1608437 else if(attack==wCByrna && byrnaid!=-1)
13018 {
13019
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!(itemsbuf[byrnaid].wpn))
13020 {
13021 attack = wNone;
13022 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
13023 }
13024
13025 30 bool beamcount = false;
13026
13027
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 55 times.
81 for(int32_t i=0; i<Lwpns.Count(); i++)
13028 {
13029 55 weapon *w = ((weapon*)Lwpns.spr(i));
13030
13031
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 4 times.
55 if(w->id==wCByrna)
13032 {
13033 4 beamcount = true;
13034 4 break;
13035 }
13036 51 }
13037
13038 // If beams already deployed, remove them
13039
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
30 if(!attackclk && beamcount)
13040 {
13041 2 return startwpn(attackid); // Remove beams instantly
13042 }
13043
13044 // Otherwise, continue
13045 28 ++attackclk;
13046 28 }
13047 else
13048 {
13049 1608407 ++attackclk;
13050
13051
6/6
✓ Branch 0 taken 4046 times.
✓ Branch 1 taken 1604361 times.
✓ Branch 2 taken 785 times.
✓ Branch 3 taken 3261 times.
✓ Branch 4 taken 485 times.
✓ Branch 5 taken 300 times.
1608407 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
13052 {
13053 300 ++attackclk; // Won't continue charging
13054 300 charging=0;
13055 300 }
13056
13057 // Faster if spinning.
13058
2/2
✓ Branch 0 taken 1605729 times.
✓ Branch 1 taken 2678 times.
1608407 if(spins>0)
13059 2678 ++attackclk;
13060
13061 // Even faster if hurricane spinning.
13062
2/2
✓ Branch 0 taken 1607975 times.
✓ Branch 1 taken 432 times.
1608407 if(spins>5)
13063 432 attackclk+=2;
13064
13065 // If at a charging threshold, do a charged attack.
13066
5/6
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 1606075 times.
✓ Branch 2 taken 2332 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2217 times.
✓ Branch 5 taken 115 times.
1608407 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
13067 {
13068
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(attack==wSword)
13069 {
13070
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3 times.
115 bool super = charging>magiccharge && scroll2id > -1;
13071
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 112 times.
115 int id = super ? scroll2id : scrollid;
13072 115 itemdata const& spinscroll = itemsbuf[id];
13073 115 bool paid = !(spinscroll.flags&ITEM_FLAG1);
13074
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if(!paid && checkbunny(id) && checkmagiccost(id))
13075 {
13076 paid = true;
13077 paymagiccost(id);
13078 }
13079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(paid)
13080 {
13081 115 currentscroll = id;
13082 115 spins=(spinscroll.misc1*4) + (super ? -3 : 1);
13083 115 attackclk=1;
13084
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 114 times.
115 if(!get_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS))
13085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
2 if(weapon* w = find_first_wtype(wSword))
13086 1 w->reset_wgrids();
13087 115 sfx(spinscroll.usesound,pan(x.getInt()));
13088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(spinscroll.flags&ITEM_FLAG1)
13089 paymagiccost(id);
13090 115 }
13091 115 }
13092 else if(attack==wHammer && sideviewhammerpound())
13093 {
13094 bool super = charging>magiccharge && scroll2id > -1;
13095 int id = super ? scroll2id : scrollid;
13096 itemdata const& quakescroll = itemsbuf[id];
13097 bool paid = !(quakescroll.flags&ITEM_FLAG1);
13098 if(!paid && checkbunny(id) && checkmagiccost(id))
13099 {
13100 paid = true;
13101 paymagiccost(id);
13102 }
13103 if(paid)
13104 {
13105 currentscroll = id;
13106 spins = super ? 2 : 1;
13107 sfx(quakescroll.usesound,pan(x.getInt()));
13108 quakeclk=quakescroll.misc1;
13109
13110 // general area stun
13111 for(int32_t i=0; i<GuyCount(); i++)
13112 {
13113 if(!isflier(GuyID(i)))
13114 {
13115 StunGuy(i,quakescroll.misc2-distance(x,y,GuyX(i),GuyY(i)));
13116 }
13117 }
13118
13119 int hmrid = (directWpn>-1 && itemsbuf[directWpn].family==itype_hammer) ? directWpn : current_item_id(itype_hammer);
13120 int hmrlvl = hmrid < 0 ? 1 : itemsbuf[hmrid].fam_type;
13121 if(hmrlvl < 1) hmrlvl = 1;
13122 int rad = quakescroll.misc2;
13123 for(int pos = 0; pos < 176; ++pos)
13124 {
13125 if(distance(x,y,COMBOX(pos),COMBOY(pos)) > rad) continue;
13126 for(int lyr = 0; lyr < 7; ++lyr)
13127 {
13128 int cid = FFCore.tempScreens[lyr]->data[pos];
13129 newcombo const& cmb = combobuf[cid];
13130 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
13131 {
13132 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
13133 ? hmrlvl <= cmb.triggerlevel
13134 : hmrlvl >= cmb.triggerlevel)
13135 do_trigger_combo(lyr,pos);
13136 }
13137 }
13138 }
13139 word c = tmpscr->numFFC();
13140 for(int ff = 0; ff < c; ++ff)
13141 {
13142 ffcdata& ffc = tmpscr->ffcs[ff];
13143 newcombo const& cmb = combobuf[ffc.data];
13144 if(distance(x,y,ffc.x,ffc.y) > rad) continue;
13145 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
13146 {
13147 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
13148 ? hmrlvl <= cmb.triggerlevel
13149 : hmrlvl >= cmb.triggerlevel)
13150 do_trigger_combo_ffc(ff);
13151 }
13152 }
13153 }
13154 }
13155 115 }
13156
6/6
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 1604221 times.
✓ Branch 2 taken 3586 times.
✓ Branch 3 taken 485 times.
✓ Branch 4 taken 347 times.
✓ Branch 5 taken 3239 times.
1608292 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
13157 3239 charging++;
13158
13159
7/8
✓ Branch 0 taken 21522 times.
✓ Branch 1 taken 1586885 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1586885 times.
✓ Branch 4 taken 25736 times.
✓ Branch 5 taken 1561149 times.
✓ Branch 6 taken 900850 times.
✓ Branch 7 taken 707557 times.
1608407 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
13160 707557 charging=0;
13161
13162
2/2
✓ Branch 0 taken 1580641 times.
✓ Branch 1 taken 27766 times.
1608407 if(attackclk>=SWORDCHARGEFRAME)
13163 27766 tapping = false;
13164 }
13165
13166
7/8
✓ Branch 0 taken 125241 times.
✓ Branch 1 taken 1517513 times.
✓ Branch 2 taken 1799 times.
✓ Branch 3 taken 123442 times.
✓ Branch 4 taken 1799 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 47 times.
✓ Branch 7 taken 1752 times.
1642754 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
13167 {
13168 1752 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
13169 }
13170
13171 1641002 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
13172
13173
11/14
✓ Branch 0 taken 1541312 times.
✓ Branch 1 taken 99690 times.
✓ Branch 2 taken 113847 times.
✓ Branch 3 taken 1427465 times.
✓ Branch 4 taken 450 times.
✓ Branch 5 taken 113397 times.
✓ Branch 6 taken 450 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 438 times.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
1641002 if(attackclk==13 || (attackclk==7 && spins>1 && attack != wHammer && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
13174 {
13175
13176
4/4
✓ Branch 0 taken 18073 times.
✓ Branch 1 taken 81629 times.
✓ Branch 2 taken 14934 times.
✓ Branch 3 taken 3139 times.
99702 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
13177
2/2
✓ Branch 0 taken 99305 times.
✓ Branch 1 taken 397 times.
99702 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
13178
13179
4/4
✓ Branch 0 taken 99305 times.
✓ Branch 1 taken 397 times.
✓ Branch 2 taken 26727 times.
✓ Branch 3 taken 72578 times.
99702 if(wpnid>=0 && itemsbuf[wpnid].flags & ITEM_FLAG1)
13180 {
13181 72578 templife=templife*game->get_maxlife();
13182 72578 templife=templife/100;
13183 72578 }
13184 else
13185 {
13186 27124 templife*=game->get_hp_per_heart();
13187 }
13188
13189
2/2
✓ Branch 0 taken 37050 times.
✓ Branch 1 taken 62652 times.
99702 bool normalbeam = (int64_t(game->get_life())+(get_qr(qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
13190 99702 int32_t perilid = current_item_id(itype_perilscroll);
13191
3/4
✓ Branch 0 taken 7415 times.
✓ Branch 1 taken 92287 times.
✓ Branch 2 taken 7415 times.
✗ Branch 3 not taken.
99773 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
13192
3/4
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 7344 times.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
7415 && checkbunny(perilid) && checkmagiccost(perilid)
13193 // Must actually be able to shoot sword beams
13194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 && ((itemsbuf[wpnid].flags & ITEM_FLAG1)
13195
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1 times.
71 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
13196
13197
4/4
✓ Branch 0 taken 84591 times.
✓ Branch 1 taken 15111 times.
✓ Branch 2 taken 531 times.
✓ Branch 3 taken 84060 times.
99702 if(attack==wSword && !tapping)
13198 {
13199
4/4
✓ Branch 0 taken 83991 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 19924 times.
✓ Branch 3 taken 64067 times.
84060 if(perilbeam || normalbeam)
13200 {
13201
1/2
✓ Branch 0 taken 19993 times.
✗ Branch 1 not taken.
19993 if(attackclk==7)
13202 paymagiccost(crossid); // Pay the Cross Beams magic cost.
13203
13204
3/4
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 19924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69 times.
19993 if(perilbeam && !normalbeam)
13205 69 paymagiccost(perilid); // Pay the Peril Beam magic cost.
13206
13207 // TODO: Something that would be cheap but disgraceful to hack in at this point is
13208 // a way to make the peril/cross beam item's power stat influence the strength
13209 // of the peril/cross beam...
13210 19993 startwpn(attackid);
13211 19993 }
13212 64067 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
13213 84060 }
13214
13215
2/2
✓ Branch 0 taken 97865 times.
✓ Branch 1 taken 1837 times.
99702 if(attack==wWand)
13216 1837 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
13217
13218
5/6
✓ Branch 0 taken 1301 times.
✓ Branch 1 taken 98401 times.
✓ Branch 2 taken 1301 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1254 times.
✓ Branch 5 taken 47 times.
99702 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
13219 47 startwpn(attackid);
13220
13221
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 99700 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
99702 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
13222 2 startwpn(attackid);
13223 99702 }
13224
13225
2/2
✓ Branch 0 taken 1542194 times.
✓ Branch 1 taken 98808 times.
1641002 if(attackclk==14)
13226 98808 lstep = s;
13227
13228 1641002 return true;
13229 1761064 }
13230
13231 26878600 bool HeroClass::can_attack()
13232 {
13233
4/4
✓ Branch 0 taken 19886 times.
✓ Branch 1 taken 26858714 times.
✓ Branch 2 taken 4006 times.
✓ Branch 3 taken 15880 times.
26878600 if(lift_wpn && (liftflags & LIFTFL_DIS_ITEMS))
13234 15880 return false;
13235
4/4
✓ Branch 0 taken 26538342 times.
✓ Branch 1 taken 324378 times.
✓ Branch 2 taken 17917618 times.
✓ Branch 3 taken 8620724 times.
26862720 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13236
4/6
✓ Branch 0 taken 26862720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26595626 times.
✓ Branch 3 taken 267094 times.
✓ Branch 4 taken 26595626 times.
✗ Branch 5 not taken.
28266392 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
13237
5/8
✓ Branch 0 taken 26595626 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26595626 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26595626 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26588718 times.
✓ Branch 7 taken 6908 times.
26595626 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
13238
3/4
✓ Branch 0 taken 26588718 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23267438 times.
✓ Branch 3 taken 3321280 times.
26588718 || ((action==attacking||action==sideswimattacking)
13239
2/2
✓ Branch 0 taken 740850 times.
✓ Branch 1 taken 25847868 times.
26588718 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5))
13240
2/2
✓ Branch 0 taken 26510690 times.
✓ Branch 1 taken 662822 times.
26588718 && charging!=0))
13241 {
13242 1677674 return false;
13243 }
13244
13245 26510690 int32_t r = (isdungeon()) ? 16 : 0;
13246 26510690 int32_t r2 = get_qr(qr_NOBORDER) ? 0 : 8;
13247
13248
4/5
✓ Branch 0 taken 7285272 times.
✓ Branch 1 taken 19225418 times.
✓ Branch 2 taken 8484792 times.
✓ Branch 3 taken 10740626 times.
✗ Branch 4 not taken.
26510690 if(!get_qr(qr_ITEMSONEDGES)) switch(dir)
13249 {
13250 case up:
13251 case down:
13252
2/2
✓ Branch 0 taken 8184744 times.
✓ Branch 1 taken 300048 times.
8484792 return !(y<(r2+r) || y>(160-r-r2));
13253
13254 case left:
13255 case right:
13256
2/2
✓ Branch 0 taken 10451638 times.
✓ Branch 1 taken 288988 times.
10740626 return !(x<(r2+r) || x>(240-r-r2));
13257 }
13258
13259 7285272 return true;
13260 28204244 }
13261
13262 16775 bool isRaftFlag(int32_t flag)
13263 {
13264
4/4
✓ Branch 0 taken 8791 times.
✓ Branch 1 taken 7984 times.
✓ Branch 2 taken 255 times.
✓ Branch 3 taken 8536 times.
16775 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
13265 }
13266
13267 7502617 void handle_lens_triggers(int32_t l_id)
13268 {
13269
2/2
✓ Branch 0 taken 7496358 times.
✓ Branch 1 taken 6259 times.
7502617 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & ITEM_FLAG6);
13270
2/2
✓ Branch 0 taken 7502617 times.
✓ Branch 1 taken 52518319 times.
60020936 for(auto layer = 0; layer < 7; ++layer)
13271 {
13272 52518319 mapscr* tmp = FFCore.tempScreens[layer];
13273
2/2
✓ Branch 0 taken 9243224144 times.
✓ Branch 1 taken 52518319 times.
9295742463 for(auto pos = 0; pos < 176; ++pos)
13274 {
13275 9243224144 newcombo const& cmb = combobuf[tmp->data[pos]];
13276
4/4
✓ Branch 0 taken 280896 times.
✓ Branch 1 taken 9242943248 times.
✓ Branch 2 taken 9243223958 times.
✓ Branch 3 taken 186 times.
9243224144 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
13277 9242943248 : (cmb.triggerflags[1] & combotriggerLENSOFF))
13278 {
13279 186 do_trigger_combo(layer, pos);
13280 186 }
13281 9243224144 }
13282 52518319 }
13283
2/2
✓ Branch 0 taken 6529490 times.
✓ Branch 1 taken 973127 times.
7502617 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
13284 {
13285 973127 word c = tmpscr->numFFC();
13286
2/2
✓ Branch 0 taken 2950366 times.
✓ Branch 1 taken 973127 times.
3923493 for(word i=0; i<c; i++)
13287 {
13288 2950366 ffcdata& ffc = tmpscr->ffcs[i];
13289 2950366 newcombo const& cmb = combobuf[ffc.data];
13290
3/4
✓ Branch 0 taken 1596 times.
✓ Branch 1 taken 2948770 times.
✓ Branch 2 taken 2950366 times.
✗ Branch 3 not taken.
2950366 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
13291 2948770 : (cmb.triggerflags[1] & combotriggerLENSOFF))
13292 {
13293 do_trigger_combo_ffc(i);
13294 }
13295 2950366 }
13296 973127 }
13297 7502617 }
13298
13299 13566531 void do_lens()
13300 {
13301
2/2
✓ Branch 0 taken 6063914 times.
✓ Branch 1 taken 7502617 times.
13566531 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
13302 {
13303 6063914 do_210_lens();
13304 6063914 return;
13305 }
13306
13307 7502617 int32_t wpnPressed = getWpnPressed(itype_lens);
13308
6/6
✓ Branch 0 taken 6256 times.
✓ Branch 1 taken 7496361 times.
✓ Branch 2 taken 375 times.
✓ Branch 3 taken 7495986 times.
✓ Branch 4 taken 390142 times.
✓ Branch 5 taken 7105844 times.
7502617 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
13309
2/2
✓ Branch 0 taken 6031155 times.
✓ Branch 1 taken 1471462 times.
7502617 if(itemid >= 0)
13310 {
13311
8/10
✓ Branch 0 taken 5343 times.
✓ Branch 1 taken 1466119 times.
✓ Branch 2 taken 5343 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 4650 times.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 166 times.
✓ Branch 9 taken 527 times.
1471462 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
13312 {
13313
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 209 times.
527 if(lensid<0)
13314 {
13315 209 lensid=itemid;
13316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(itemsbuf[itemid].family == itype_lens)
13317 209 Hero.setLastLensID(itemid);
13318
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 12 times.
209 if(get_qr(qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
13319 209 }
13320
13321 527 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
13322
13323
2/10
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 527 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
527 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
13324 {
13325 //clear the item script stack for a new script
13326 int i = itemid;
13327 FFCore.reset_script_engine_data(ScriptType::Item, i);
13328 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
13329 did_scriptl=true;
13330 }
13331
13332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
13333 527 else lensclk = 12;
13334 527 }
13335 else
13336 {
13337 1470935 did_scriptl=false;
13338
2/2
✓ Branch 0 taken 1465203 times.
✓ Branch 1 taken 5732 times.
1470935 if(!lensclk)
13339 {
13340
13341
2/2
✓ Branch 0 taken 1464997 times.
✓ Branch 1 taken 206 times.
1465203 if(lensid>-1)
13342 {
13343 206 lensid=-1;
13344 206 lensclk = 0;
13345
13346
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 11 times.
206 if(get_qr(qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
13347 206 }
13348 1465203 }
13349 }
13350 1471462 }
13351 7502617 handle_lens_triggers(lensid);
13352 13566531 }
13353
13354 6063914 void do_210_lens()
13355 {
13356 6063914 int32_t wpnPressed = getWpnPressed(itype_lens);
13357
4/4
✓ Branch 0 taken 3334 times.
✓ Branch 1 taken 6060580 times.
✓ Branch 2 taken 487 times.
✓ Branch 3 taken 6060093 times.
6063914 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>-1 ? wpnPressed : current_item_id(itype_lens);
13358
2/2
✓ Branch 0 taken 1226986 times.
✓ Branch 1 taken 4836928 times.
6063914 if(itemid<0)
13359 4836928 return;
13360
13361
7/8
✓ Branch 0 taken 3343 times.
✓ Branch 1 taken 1223643 times.
✓ Branch 2 taken 3343 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 2821 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 515 times.
1226986 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
13362 {
13363
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 480 times.
515 if(lensid<0)
13364 {
13365 480 lensid=itemid;
13366
13367
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(get_qr(qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
13368 480 }
13369
13370 515 paymagiccost(itemid, true);
13371
13372
2/10
✓ Branch 0 taken 515 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 515 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
515 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
13373 {
13374 //clear the item script stack for a new script
13375 int i = itemid;
13376 FFCore.reset_script_engine_data(ScriptType::Item, i);
13377 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
13378 did_scriptl=true;
13379 }
13380
13381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515 times.
515 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
13382 515 else lensclk = 12;
13383 515 }
13384 else
13385 {
13386 1226471 did_scriptl=false;
13387
13388
7/8
✓ Branch 0 taken 3299 times.
✓ Branch 1 taken 1223172 times.
✓ Branch 2 taken 2821 times.
✓ Branch 3 taken 478 times.
✓ Branch 4 taken 2821 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2820 times.
✓ Branch 7 taken 1 times.
1226471 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
13389 {
13390 479 lensid=-1;
13391 479 lensclk = 0;
13392
13393
1/2
✓ Branch 0 taken 479 times.
✗ Branch 1 not taken.
479 if(get_qr(qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
13394 479 }
13395 }
13396 6063914 }
13397
13398 14081 void HeroClass::do_hopping()
13399 {
13400 14081 do_lens();
13401
13402
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 13527 times.
14081 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
13403 //Possible fix for exiting water in diagonal movement. -Z
13404 {
13405 554 int32_t flippers_id = current_item_id(itype_flippers);
13406
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 550 times.
554 if(diveclk>0)
13407 {
13408 4 --diveclk;
13409
2/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
13410 {
13411 diveclk = itemsbuf[flippers_id].misc2;
13412 }
13413 4 }
13414
2/2
✓ Branch 0 taken 548 times.
✓ Branch 1 taken 2 times.
550 else if(DrunkrAbtn())
13415 {
13416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
13417 2 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
13418
13419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(global_diving==screen_diving)
13420
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13421 2 }
13422
13423
6/8
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 156 times.
✓ Branch 3 taken 398 times.
✓ Branch 4 taken 156 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 156 times.
554 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
13424 {
13425 398 SetSwim();
13426 398 hopclk = 0;
13427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (!IsSideSwim())
13428 {
13429 398 charging = attackclk = 0;
13430 398 tapping = false;
13431 398 }
13432 398 }
13433 else
13434 {
13435 156 herostep();
13436
13437
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
156 if(!isDiving() || (frame&1))
13438 {
13439
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 77 times.
156 switch(dir)
13440 {
13441 case up:
13442 42 y -= 1;
13443 42 break;
13444
13445 case down:
13446 7 y += 1;
13447 7 break;
13448
13449 case left:
13450 30 x -= 1;
13451 30 break;
13452
13453 case right:
13454 77 x += 1;
13455 77 break;
13456 }
13457 156 }
13458 }
13459 554 }
13460 else // hopping in or out (need to separate the cases...)
13461 {
13462
4/6
✓ Branch 0 taken 12509 times.
✓ Branch 1 taken 1018 times.
✓ Branch 2 taken 12509 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12509 times.
13527 if((diagonalMovement||NO_GRIDLOCK))
13463 {
13464
2/2
✓ Branch 0 taken 643 times.
✓ Branch 1 taken 375 times.
1018 if(hopclk==1) //hopping out
13465 //>= 1 possible fix for getting stuck on land edges.
13466 //No, this is not a clock. it's a type. 1 == out, 2 == in.
13467 {
13468
1/2
✓ Branch 0 taken 375 times.
✗ Branch 1 not taken.
375 if(hopdir!=-1) dir=hopdir;
13469
13470 375 landswim=0;
13471
13472
2/2
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 101 times.
375 if(dir==up)
13473 {
13474 101 herostep();
13475 101 herostep();
13476 101 int32_t sidestep=0;
13477
13478
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 101 times.
101 if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13479 sidestep=1;
13480
3/6
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101 times.
✗ Branch 5 not taken.
101 else if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13481 sidestep=2;
13482
13483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if(sidestep==1) x++;
13484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 else if(sidestep==2) x--;
13485 101 else y--;
13486
13487
3/4
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 8 times.
101 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
13488 {
13489 8 hopclk=0;
13490 8 diveclk=0;
13491 8 action=none; FFCore.setHeroAction(none);
13492 8 hopdir=-1;
13493 8 }
13494 101 }
13495
13496
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 72 times.
375 if(dir==down)
13497 {
13498 72 herostep();
13499 72 herostep();
13500 72 int32_t sidestep=0;
13501
13502
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 72 times.
72 if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
13503 sidestep=1;
13504
3/6
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
72 else if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
13505 sidestep=2;
13506
13507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(sidestep==1) x++;
13508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 else if(sidestep==2) x--;
13509 72 else y++;
13510
13511
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
72 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
13512 {
13513 6 hopclk=0;
13514 6 diveclk=0;
13515 6 action=none; FFCore.setHeroAction(none);
13516 6 hopdir=-1;
13517 6 }
13518 72 }
13519
13520
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 57 times.
375 if(dir==left)
13521 {
13522 57 herostep();
13523 57 herostep();
13524 57 int32_t sidestep=0;
13525
13526
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
57 if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
13527 sidestep=1;
13528
3/6
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
57 else if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
13529 sidestep=2;
13530
13531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(sidestep==1) y++;
13532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 else if(sidestep==2) y--;
13533 57 else x--;
13534
13535
3/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 4 times.
57 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
13536 {
13537 4 hopclk=0;
13538 4 diveclk=0;
13539 4 action=none; FFCore.setHeroAction(none);
13540 4 hopdir=-1;
13541 4 }
13542 57 }
13543
13544
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 145 times.
375 if(dir==right)
13545 {
13546 145 herostep();
13547 145 herostep();
13548 145 int32_t sidestep=0;
13549
13550
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 145 times.
145 if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
13551 sidestep=1;
13552
3/6
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145 times.
✓ Branch 4 taken 145 times.
✗ Branch 5 not taken.
145 else if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
13553 sidestep=2;
13554
13555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
145 if(sidestep==1) y++;
13556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
145 else if(sidestep==2) y--;
13557 145 else x++;
13558
13559
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 134 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
145 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
13560 {
13561 11 hopclk=0;
13562 11 diveclk=0;
13563 11 action=none; FFCore.setHeroAction(none);
13564 11 hopdir=-1;
13565 11 }
13566 145 }
13567 375 }
13568
13569
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 643 times.
1018 if(hopclk==2) //hopping in
13570 {
13571 643 landswim=0;
13572
13573
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 89 times.
643 if(dir==up)
13574 {
13575 89 herostep();
13576 89 herostep();
13577 89 int32_t sidestep=0;
13578
13579
6/6
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 88 times.
89 if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13580 1 sidestep=1;
13581
4/6
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
88 else if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13582 sidestep=2;
13583
13584
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 88 times.
89 if(sidestep==1) x++;
13585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 else if(sidestep==2) x--;
13586 88 else y--;
13587
13588
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 4 times.
89 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
13589 {
13590 4 hopclk=0xFF;
13591 4 diveclk=0;
13592 4 SetSwim();
13593 4 }
13594 89 }
13595
13596
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 142 times.
643 if(dir==down)
13597 {
13598 142 herostep();
13599 142 herostep();
13600 142 int32_t sidestep=0;
13601
13602
3/6
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 142 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 142 times.
142 if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
13603 sidestep=1;
13604
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 142 times.
✗ Branch 5 not taken.
142 else if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
13605 sidestep=2;
13606
13607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if(sidestep==1) x++;
13608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if(sidestep==2) x--;
13609 142 else y++;
13610
13611
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
142 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
13612 {
13613 hopclk=0xFF;
13614 diveclk=0;
13615 SetSwim();
13616 if (!IsSideSwim()) reset_swordcharge();
13617 }
13618 142 }
13619
13620
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 133 times.
643 if(dir==left)
13621 {
13622 133 herostep();
13623 133 herostep();
13624 133 int32_t sidestep=0;
13625
13626
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
13627 sidestep=1;
13628
4/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
133 else if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
13629 sidestep=2;
13630
13631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if(sidestep==1) y++;
13632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 else if(sidestep==2) y--;
13633 133 else x--;
13634
13635
4/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 95 times.
133 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
13636 {
13637 7 hopclk=0xFF;
13638 7 diveclk=0;
13639 7 SetSwim();
13640 7 }
13641 133 }
13642
13643
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 279 times.
643 if(dir==right)
13644 {
13645 279 herostep();
13646 279 herostep();
13647
13648 279 int32_t sidestep=0;
13649
13650
4/6
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 279 times.
279 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
13651 sidestep=1;
13652
4/6
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 279 times.
✗ Branch 5 not taken.
279 else if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
13653 sidestep=2;
13654
13655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(sidestep==1) y++;
13656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 else if(sidestep==2) y--;
13657 279 else x++;
13658
13659
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
279 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
13660 {
13661 5 hopclk=0xFF;
13662 5 diveclk=0;
13663 5 SetSwim();
13664 5 }
13665 279 }
13666 643 }
13667
13668 1018 }
13669 else
13670 {
13671
7/8
✓ Branch 0 taken 4823 times.
✓ Branch 1 taken 7686 times.
✓ Branch 2 taken 4823 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3622 times.
✓ Branch 5 taken 1201 times.
✓ Branch 6 taken 640 times.
✓ Branch 7 taken 7046 times.
12509 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
13672 {
13673 1201 action=none; FFCore.setHeroAction(none);
13674 1201 hopclk = 0;
13675 1201 diveclk = 0;
13676
13677
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 625 times.
1201 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+8), currmap, currscr, -1, x.getInt(),y.getInt()+8, true, false))
13678 {
13679 // hopped in
13680 625 SetSwim();
13681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625 times.
625 if (!IsSideSwim()) attackclk = charging = spins = 0;
13682 625 }
13683 1201 }
13684 else
13685 {
13686 11308 herostep();
13687 11308 herostep();
13688
13689
2/2
✓ Branch 0 taken 10642 times.
✓ Branch 1 taken 666 times.
11308 if(++hero_count>(16*hero_animation_speed))
13690 666 hero_count=0;
13691
13692 11308 int32_t xofs2 = x.getInt()&15;
13693 11308 int32_t yofs2 = y.getInt()&15;
13694 11308 int32_t s = 1 + (frame&1);
13695
13696
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 2606 times.
✓ Branch 3 taken 3402 times.
✓ Branch 4 taken 3644 times.
11308 switch(dir)
13697 {
13698 case up:
13699
4/4
✓ Branch 0 taken 1173 times.
✓ Branch 1 taken 483 times.
✓ Branch 2 taken 1167 times.
✓ Branch 3 taken 6 times.
1656 if(yofs2<3 || yofs2>13) --y;
13700 1167 else y-=s;
13701
13702 1656 break;
13703
13704 case down:
13705
4/4
✓ Branch 0 taken 2152 times.
✓ Branch 1 taken 454 times.
✓ Branch 2 taken 356 times.
✓ Branch 3 taken 1796 times.
2606 if(yofs2<3 || yofs2>13) ++y;
13706 1796 else y+=s;
13707
13708 2606 break;
13709
13710 case left:
13711
4/4
✓ Branch 0 taken 2966 times.
✓ Branch 1 taken 436 times.
✓ Branch 2 taken 598 times.
✓ Branch 3 taken 2368 times.
3402 if(xofs2<3 || xofs2>13) --x;
13712 2368 else x-=s;
13713
13714 3402 break;
13715
13716 case right:
13717
4/4
✓ Branch 0 taken 3009 times.
✓ Branch 1 taken 635 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 2517 times.
3644 if(xofs2<3 || xofs2>13) ++x;
13718 2517 else x+=s;
13719
13720 3644 break;
13721 }
13722 }
13723 }
13724 }
13725 14081 }
13726
13727 113150 void HeroClass::do_rafting()
13728 {
13729
13730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 if(toogam)
13731 {
13732 action=none; FFCore.setHeroAction(none);
13733 return;
13734 }
13735
13736 113150 FFCore.setHeroAction(rafting);
13737
13738 113150 do_lens();
13739
13740 113150 herostep();
13741
13742 //Calculate rafting speed
13743 113150 int32_t raft_item = current_item_id(itype_raft);
13744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
13745 113150 raft_step = vbound(raft_step, -8, 5);
13746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
13747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 if(raft_step < 0) raft_step = 1;
13748 113150 int32_t step_inc = 1 << (raft_step - 1);
13749 // Fix position
13750
1/2
✓ Branch 0 taken 113150 times.
✗ Branch 1 not taken.
113150 if(raft_step > 1)
13751 {
13752 if(x.getInt() & (step_inc-1))
13753 {
13754 x = x.getInt() & ~(step_inc-1);
13755 }
13756 if(y.getInt() & (step_inc-1))
13757 {
13758 y = y.getInt() & ~(step_inc-1);
13759 }
13760 }
13761 // Inc clock, check if we need to move this frame
13762 113150 ++raftclk;
13763
2/4
✓ Branch 0 taken 113150 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113150 times.
113150 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
13764
13765
4/4
✓ Branch 0 taken 54339 times.
✓ Branch 1 taken 58811 times.
✓ Branch 2 taken 46510 times.
✓ Branch 3 taken 7829 times.
120836 if(!(x.getInt()&15) && !(y.getInt()&15))
13766 {
13767 // this sections handles switching to raft branches
13768
3/4
✓ Branch 0 taken 7575 times.
✓ Branch 1 taken 254 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7575 times.
7829 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
13769 {
13770
7/8
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 139 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 35 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
254 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13771 {
13772 35 dir = up;
13773 35 goto skip;
13774 }
13775
13776
7/8
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 48 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
219 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13777 {
13778 48 dir = down;
13779 48 goto skip;
13780 }
13781
13782
7/8
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 31 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
171 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13783 {
13784 31 dir = left;
13785 31 goto skip;
13786 }
13787
13788
7/8
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
140 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13789 {
13790 29 dir = right;
13791 29 goto skip;
13792 }
13793 111 }
13794
2/4
✓ Branch 0 taken 7575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7575 times.
7575 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
13795 {
13796 if(dir == left) dir = right;
13797 else if(dir == right) dir = left;
13798 else if(dir == up) dir = down;
13799 else if(dir == down) dir = up;
13800 }
13801
13802
13803
4/4
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 6304 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 1371 times.
7686 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
13804 {
13805
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 632 times.
1371 if(dir<left) //going up or down
13806 {
13807
3/4
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 269 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 470 times.
739 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13808 269 dir=right;
13809
3/4
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 241 times.
470 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13810 229 dir=left;
13811
4/4
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 16 times.
241 else if(y>0 && y<160)
13812 {
13813 210 action=none; FFCore.setHeroAction(none);
13814 210 x = x.getInt();
13815 210 y = y.getInt();
13816 210 }
13817 739 }
13818 else //going left or right
13819 {
13820
3/4
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 389 times.
632 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13821 243 dir=down;
13822
3/4
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147 times.
389 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13823 242 dir=up;
13824
4/4
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 145 times.
147 else if(x>0 && x<240)
13825 {
13826 145 action=none; FFCore.setHeroAction(none);
13827 145 x = x.getInt();
13828 145 y = y.getInt();
13829 145 }
13830 }
13831 1371 }
13832 7686 }
13833
13834 skip:
13835
13836
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 25101 times.
✓ Branch 2 taken 24965 times.
✓ Branch 3 taken 29470 times.
✓ Branch 4 taken 33614 times.
113150 switch(dir)
13837 {
13838 case up:
13839
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 25092 times.
25101 if(x.getInt()&15)
13840 {
13841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(x.getInt()&8)
13842 x++;
13843 9 else x--;
13844 9 }
13845 25092 else y -= step_inc;
13846
13847 25101 break;
13848
13849 case down:
13850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24965 times.
24965 if(x.getInt()&15)
13851 {
13852 if(x.getInt()&8)
13853 x++;
13854 else x--;
13855 }
13856 24965 else y += step_inc;
13857
13858 24965 break;
13859
13860 case left:
13861
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 29464 times.
29470 if(y.getInt()&15)
13862 {
13863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (get_qr(qr_BETTER_RAFT_2))
13864 {
13865 if ((y.getInt() % 16) < 4) y--;
13866 else y++;
13867 }
13868 else
13869 {
13870
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(y.getInt()&8)
13871 6 y++;
13872 else y--;
13873 }
13874 6 }
13875 29464 else x -= step_inc;
13876
13877 29470 break;
13878
13879 case right:
13880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33614 times.
33614 if(y.getInt()&15)
13881 {
13882 if (get_qr(qr_BETTER_RAFT_2))
13883 {
13884 if ((y.getInt() % 16) <= 4) y--;
13885 else y++;
13886 }
13887 else
13888 {
13889 if(y.getInt()&8)
13890 y++;
13891 else y--;
13892 }
13893 }
13894 33614 else x += step_inc;
13895
13896 33614 break;
13897 }
13898 113150 }
13899
13900 271 bool HeroClass::try_hover()
13901 {
13902
6/10
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 269 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
271 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
13903 {
13904 2 int32_t itemid = current_item_id(itype_hoverboots);
13905
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hoverclk < 0)
13906 hoverclk = -hoverclk;
13907 else
13908 {
13909 2 fall = fakefall = jumping = 0;
13910
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].misc1)
13911 2 hoverclk = itemsbuf[itemid].misc1;
13912 else
13913 {
13914 hoverclk = 1;
13915 hoverflags |= HOV_INF;
13916 }
13917
13918
13919 2 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
13920 }
13921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(itemsbuf[itemid].wpn)
13922
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 decorations.add(new dHover(x, y, dHOVER, 0));
13923 2 return true;
13924 }
13925 269 return false;
13926 271 }
13927
13928 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
13929 //Returns '-1' if not being pulled
13930 //Returns '-2' if should be falling in
13931 53866639 int32_t HeroClass::check_pitslide(bool ignore_hover)
13932 {
13933 //Pitfall todo -Emily
13934 //Iron boots; can't fight slipping, 2px/frame
13935 //Scripted variables to read pull dir/clk (clk only for non-hero)
13936 //Implement falling for all sprite types (npc AI)
13937 // Fall/slipping tiles for enemies
13938 // Fall/slipping SFX for enemies
13939 // Fall SFX for items/weapons
13940 // Weapons/Misc sprite shared for falling items/weapons
13941 //Maybe slip SFX for Hero?
13942 // Weapons/Misc sprite override for falling sprite?
13943 //Update std.zh with relevant new stuff
13944
2/2
✓ Branch 0 taken 1409149 times.
✓ Branch 1 taken 52457490 times.
53866639 if(can_pitfall(ignore_hover))
13945 {
13946
2/2
✓ Branch 0 taken 16407954 times.
✓ Branch 1 taken 36049536 times.
52457490 bool can_diag = (diagonalMovement || get_qr(qr_DISABLE_4WAY_GRIDLOCK));
13947 52457490 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
13948 52457490 int32_t ispitbl = getpitfall(x,y+15);
13949 52457490 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
13950 52457490 int32_t ispitbr = getpitfall(x+15,y+15);
13951 52457490 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
13952 52457490 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
13953 52457490 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
13954 52457490 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
13955 52457490 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
13956 52457490 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
13957 52457490 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
13958 52457490 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
13959 static const int32_t flag_pit_irresistable = (1<<24);
13960
5/5
✓ Branch 0 taken 52390477 times.
✓ Branch 1 taken 7722 times.
✓ Branch 2 taken 914 times.
✓ Branch 3 taken 34895 times.
✓ Branch 4 taken 23482 times.
52457490 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
13961 {
13962 7722 case 4: return -2; //Fully over pit; fall in
13963 case 3:
13964 {
13965
6/6
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 468 times.
✓ Branch 2 taken 276 times.
✓ Branch 3 taken 170 times.
✓ Branch 4 taken 254 times.
✓ Branch 5 taken 22 times.
914 if(ispitul && ispitur && ispitbl) //UL_3
13966 {
13967
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(ispitul_50)
13968 {
13969
3/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13970 6 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13971 }
13972 }
13973
5/6
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 468 times.
✓ Branch 2 taken 254 times.
✓ Branch 3 taken 170 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 254 times.
892 else if(ispitul && ispitur && ispitbr) //UR_3
13974 {
13975
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 215 times.
254 if(ispitur_50)
13976 {
13977
5/6
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
39 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13978 23 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13979 }
13980 215 }
13981
4/6
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 468 times.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 170 times.
638 else if(ispitul && ispitbl && ispitbr) //BL_3
13982 {
13983
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 156 times.
170 if(ispitbl_50)
13984 {
13985
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
14 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13986 14 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13987 }
13988 156 }
13989
3/6
✓ Branch 0 taken 468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 468 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 468 times.
468 else if(ispitbl && ispitur && ispitbr) //BR_3
13990 {
13991
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 464 times.
468 if(ispitbr_50)
13992 {
13993
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13994 4 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13995 }
13996 464 }
13997 835 break;
13998 }
13999 case 2:
14000 {
14001
4/4
✓ Branch 0 taken 18228 times.
✓ Branch 1 taken 16667 times.
✓ Branch 2 taken 15791 times.
✓ Branch 3 taken 2437 times.
34895 if(ispitul && ispitur) //Up
14002 {
14003
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 2323 times.
2437 if(DrunkDown())
14004 {
14005
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if(ispitul_75 && ispitur_75) //Straight up
14006 {
14007 return up | flag_pit_irresistable | (ispitul << 8);
14008 }
14009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 else if(ispitul_75)
14010 {
14011 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
14012 }
14013
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 else if(ispitur_75)
14014 {
14015 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
14016 }
14017 114 else return -1;
14018 }
14019 else
14020 {
14021
3/4
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 2121 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202 times.
2323 if(ispitul_50 && ispitur_50) //Straight up
14022 {
14023
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 132 times.
202 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
14024 }
14025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2121 times.
2121 else if(ispitul_50)
14026 {
14027 if(DrunkRight() && !ispitul_75) return -1;
14028 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
14029 }
14030
1/2
✓ Branch 0 taken 2121 times.
✗ Branch 1 not taken.
2121 else if(ispitur_50)
14031 {
14032 if(DrunkLeft() && !ispitur_75) return -1;
14033 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
14034 }
14035 }
14036 2121 }
14037
4/4
✓ Branch 0 taken 18742 times.
✓ Branch 1 taken 13716 times.
✓ Branch 2 taken 15775 times.
✓ Branch 3 taken 2967 times.
32458 else if(ispitbl && ispitbr) //Down
14038 {
14039
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 2893 times.
2967 if(DrunkUp())
14040 {
14041
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
74 if(ispitbl_75 && ispitbr_75) //Straight down
14042 {
14043 4 return down | flag_pit_irresistable | (ispitbl << 8);
14044 }
14045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 else if(ispitbl_75)
14046 {
14047 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
14048 }
14049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 else if(ispitbr_75)
14050 {
14051 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
14052 }
14053 70 else return -1;
14054 }
14055 else
14056 {
14057
3/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2843 times.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
2893 if(ispitbl_50 && ispitbr_50) //Straight down
14058 {
14059
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 40 times.
50 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
14060 }
14061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2843 times.
2843 else if(ispitbl_50)
14062 {
14063 if(DrunkRight() && !ispitbl_75) return -1;
14064 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
14065 }
14066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2843 times.
2843 else if(ispitbr_50)
14067 {
14068 if(DrunkLeft() && !ispitbr_75) return -1;
14069 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
14070 }
14071 }
14072 2843 }
14073
3/4
✓ Branch 0 taken 15775 times.
✓ Branch 1 taken 13716 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15775 times.
29491 else if(ispitbl && ispitul) //Left
14074 {
14075
2/2
✓ Branch 0 taken 836 times.
✓ Branch 1 taken 14939 times.
15775 if(DrunkRight())
14076 {
14077
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 836 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
836 if(ispitul_75 && ispitbl_75) //Straight left
14078 {
14079 return left | flag_pit_irresistable | (ispitul << 8);
14080 }
14081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836 times.
836 else if(ispitul_75)
14082 {
14083 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
14084 }
14085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836 times.
836 else if(ispitbl_75)
14086 {
14087 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
14088 }
14089 836 else return -1;
14090 }
14091 else
14092 {
14093
3/4
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 14519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 420 times.
14939 if(ispitul_50 && ispitbl_50) //Straight left
14094 {
14095
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 315 times.
420 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
14096 }
14097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14519 times.
14519 else if(ispitul_50)
14098 {
14099 if(DrunkDown() && !ispitul_75) return -1;
14100 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
14101 }
14102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14519 times.
14519 else if(ispitbl_50)
14103 {
14104 if(DrunkUp() && !ispitbl_75) return -1;
14105 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
14106 }
14107 }
14108 14519 }
14109
3/4
✓ Branch 0 taken 13716 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 13700 times.
13716 else if(ispitbr && ispitur) //Right
14110 {
14111
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 12904 times.
13700 if(DrunkLeft())
14112 {
14113
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 777 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
796 if(ispitur_75 && ispitbr_75) //Straight right
14114 {
14115 19 return right | flag_pit_irresistable | (ispitur << 8);
14116 }
14117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777 times.
777 else if(ispitur_75)
14118 {
14119 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
14120 }
14121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777 times.
777 else if(ispitbr_75)
14122 {
14123 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
14124 }
14125 777 else return -1;
14126 }
14127 else
14128 {
14129
3/4
✓ Branch 0 taken 530 times.
✓ Branch 1 taken 12374 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 530 times.
12904 if(ispitur_50 && ispitbr_50) //Straight right
14130 {
14131
2/2
✓ Branch 0 taken 368 times.
✓ Branch 1 taken 162 times.
530 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
14132 }
14133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12374 times.
12374 else if(ispitur_50)
14134 {
14135 if(DrunkDown() && !ispitur_75) return -1;
14136 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
14137 }
14138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12374 times.
12374 else if(ispitbr_50)
14139 {
14140 if(DrunkUp() && !ispitbr_75) return -1;
14141 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
14142 }
14143 }
14144 12374 }
14145 31873 break;
14146 }
14147 case 1:
14148 {
14149
4/4
✓ Branch 0 taken 7279 times.
✓ Branch 1 taken 16203 times.
✓ Branch 2 taken 7274 times.
✓ Branch 3 taken 5 times.
23482 if(ispitul && ispitul_50) //UL_1
14150 {
14151
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
5 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
14152 5 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
14153 }
14154
4/4
✓ Branch 0 taken 5486 times.
✓ Branch 1 taken 17991 times.
✓ Branch 2 taken 5399 times.
✓ Branch 3 taken 87 times.
23477 if(ispitur && ispitur_50) //UR_1
14155 {
14156
5/6
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 57 times.
✓ Branch 5 taken 14 times.
87 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
14157 14 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
14158 }
14159
4/4
✓ Branch 0 taken 4339 times.
✓ Branch 1 taken 19051 times.
✓ Branch 2 taken 4336 times.
✓ Branch 3 taken 3 times.
23390 if(ispitbl && ispitbl_50) //BL_1
14160 {
14161
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
14162 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
14163 }
14164
4/4
✓ Branch 0 taken 6378 times.
✓ Branch 1 taken 17009 times.
✓ Branch 2 taken 6324 times.
✓ Branch 3 taken 54 times.
23387 if(ispitbr && ispitbr_50) //BR_1
14165 {
14166
5/6
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 5 times.
54 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
14167 5 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
14168 }
14169 23333 break;
14170 }
14171 }
14172 52446518 }
14173 53855667 return -1;
14174 53866639 }
14175
14176 11843625 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
14177 {
14178 11843625 pitfall();
14179
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 11843607 times.
11843625 if(fallclk) return true;
14180 11843607 int32_t val = check_pitslide();
14181 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
14182
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 11843390 times.
11843607 if(val == -1)
14183 {
14184 11843390 pit_pulldir = -1;
14185 11843390 pit_pullclk = 0;
14186 11843390 return false;
14187 }
14188 217 int32_t dir = val&0xFF;
14189 217 int32_t cmbid = (val&0xFFFF00)>>8;
14190 217 int32_t sensitivity = combobuf[cmbid].attribytes[2];
14191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
14192 {
14193 pit_pulldir = -1;
14194 pit_pullclk = 0;
14195 return false;
14196 }
14197
4/6
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 215 times.
✓ Branch 5 taken 2 times.
217 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
14198 {
14199 2 pit_pulldir = -1;
14200 2 pit_pullclk = 0;
14201 2 return false;
14202 }
14203 215 pit_pulldir = dir;
14204 215 int32_t step = 1;
14205
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 10 times.
215 if(sensitivity == 0)
14206 {
14207 10 step = 2;
14208 10 sensitivity = 1;
14209 10 }
14210
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 158 times.
215 if(pit_pullclk++ % sensitivity) //No pull this frame
14211 57 return (val&0x100);
14212
4/4
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 158 times.
324 for(; step > 0 && !fallclk; --step)
14213 {
14214
3/3
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 41 times.
166 switch(dir)
14215 {
14216 case l_up: case l_down: case left:
14217 52 --x; break;
14218 case r_up: case r_down: case right:
14219 73 ++x; break;
14220 }
14221
3/3
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 117 times.
166 switch(dir)
14222 {
14223 case l_up: case r_up: case up:
14224 37 --y; break;
14225 case l_down: case r_down: case down:
14226 12 ++y; break;
14227 }
14228 166 pitfall();
14229 166 }
14230
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 36 times.
158 return fallclk || (val&0x100);
14231 11843625 }
14232
14233 11847571 void HeroClass::pitfall()
14234 {
14235
2/2
✓ Branch 0 taken 3780 times.
✓ Branch 1 taken 11843791 times.
11847571 if(fallclk)
14236 {
14237 3780 drop_liftwpn();
14238
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 3726 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
3780 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
14239 //Handle falling
14240
2/2
✓ Branch 0 taken 3726 times.
✓ Branch 1 taken 54 times.
3780 if(!--fallclk)
14241 {
14242 54 std::vector<int32_t> &ev = FFCore.eventData;
14243 54 ev.clear();
14244 54 ev.push_back(fallCombo*10000);
14245
14246 54 throwGenScriptEvent(GENSCR_EVENT_PLAYER_FALL);
14247
14248 54 fallCombo = ev[0]/10000;
14249
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
54 if(fallCombo < 0 || fallCombo >= MAXCOMBOS)
14250 fallCombo = 0;
14251
14252 54 int32_t dmg = game->get_hp_per_heart()/4;
14253 54 bool dmg_perc = false;
14254 54 bool warp = false;
14255
14256 54 action=none; FFCore.setHeroAction(none);
14257
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
14258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(cmb)
14259 {
14260 54 dmg = cmb->attributes[0]/10000L;
14261 54 dmg_perc = cmb->usrflags&cflag3;
14262 54 warp = cmb->usrflags&cflag1;
14263 54 }
14264
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if(cheat_superman && dmg > 0)
14265 dmg = 0;
14266
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 38 times.
54 if(dmg) //Damage
14267 {
14268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(dmg > 0) hclk=48; //IFrames only if damaged, not if healed
14269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
14270 38 }
14271
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 51 times.
54 if(warp) //Warp
14272 {
14273 3 sdir = dir;
14274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(cmb->usrflags&cflag2) //Direct Warp
14275 {
14276 3 didpit=true;
14277 3 pitx=x;
14278 3 pity=y;
14279 3 }
14280 3 dowarp(0,vbound(cmb->attribytes[1],0,3),0);
14281 3 }
14282 else //Reset to screen entry
14283 {
14284 51 go_respawn_point();
14285 }
14286 54 }
14287 3780 }
14288
2/2
✓ Branch 0 taken 379433 times.
✓ Branch 1 taken 11464358 times.
11843791 else if(can_pitfall())
14289 {
14290 11464358 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
14291 11464358 bool ispitbl = ispitfall(x,y+15);
14292 11464358 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
14293 11464358 bool ispitbr = ispitfall(x+15,y+15);
14294 11464358 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
14295
9/10
✓ Branch 0 taken 4586 times.
✓ Branch 1 taken 11459772 times.
✓ Branch 2 taken 2856 times.
✓ Branch 3 taken 1730 times.
✓ Branch 4 taken 57 times.
✓ Branch 5 taken 2799 times.
✓ Branch 6 taken 54 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 54 times.
11464358 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
14296 {
14297
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
14298
3/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 42 times.
54 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
14299 54 fallclk = PITFALL_FALL_FRAMES;
14300 54 fallCombo = pitctr;
14301 54 action=falling; FFCore.setHeroAction(falling);
14302 54 spins = 0;
14303 54 charging = 0;
14304 54 drop_liftwpn();
14305 54 }
14306 11464358 }
14307 11847571 }
14308
14309 void HeroClass::handle_slide(newcombo const& icecmb, zfix& dx, zfix& dy)
14310 {
14311 bool is_inair = z || fakez;
14312 zfix odx = dx, ody = dy;
14313 if(sliding == 2 && !is_inair) //landed from air-sliding
14314 {
14315 if((ice_vx+odx).sign() != ice_vx.sign())
14316 ice_vx = 0;
14317 if((ice_vy+ody).sign() != ice_vy.sign())
14318 ice_vy = 0;
14319 sliding = 1;
14320 }
14321 if(!sliding) //just hit the ice
14322 {
14323 if(is_inair)
14324 return;
14325 sliding = 1;
14326 zfix start_perc = icecmb.attribytes[0] / 100_zf;
14327 ice_vx = dx * start_perc;
14328 ice_vy = dy * start_perc;
14329 ice_entry_count = ice_entry_mcount = icecmb.attribytes[1];
14330 }
14331 else //not the first frame sliding
14332 {
14333 if(is_inair)
14334 sliding = 2;
14335 zfix accel = zslongToFix(zc_max(1,icecmb.attributes[0]));
14336 zfix decel = zslongToFix(zc_max(1,icecmb.attributes[1]));
14337
14338 if(ice_entry_count)
14339 {
14340 if(--ice_entry_count)
14341 {
14342 zfix perc = zfix(ice_entry_count)/ice_entry_mcount;
14343 perc *= perc; //square the portion, for a better transition
14344 zfix normal_rate = zfix(steprate)/100/2;
14345 decel = (perc*normal_rate)+((1-perc)*decel);
14346 }
14347 }
14348 //!TODO Traction Boots can be added here, with a multiplier on accel/decel
14349 //Accelerate in the pushed direction
14350 if(is_inair)
14351 {
14352 static const int air_accel = 100;
14353 accel = abs(odx)/air_accel;
14354 if(accel)
14355 {
14356 if(odx < 0)
14357 {
14358 if(ice_vx - accel < odx)
14359 {
14360 if(ice_vx > odx)
14361 ice_vx = odx;
14362 else odx = 0; //allow decel
14363 }
14364 else ice_vx -= accel;
14365 }
14366 else //if(odx > 0)
14367 {
14368 if(ice_vx + accel > odx)
14369 {
14370 if(ice_vx < odx)
14371 ice_vx = odx;
14372 else odx = 0; //allow decel
14373 }
14374 else ice_vx += accel;
14375 }
14376 }
14377 accel = abs(ody)/air_accel;
14378 if(accel)
14379 {
14380 if(ody < 0)
14381 {
14382 if(ice_vy - accel < ody)
14383 {
14384 if(ice_vy > ody)
14385 ice_vy = ody;
14386 else ody = 0; //allow decel
14387 }
14388 else ice_vy -= accel;
14389 }
14390 else //if(ody > 0)
14391 {
14392 if(ice_vy + accel > ody)
14393 {
14394 if(ice_vy < ody)
14395 ice_vy = ody;
14396 else ody = 0; //allow decel
14397 }
14398 else ice_vy += accel;
14399 }
14400 }
14401 }
14402 else if(accel)
14403 {
14404 if(odx > 0)
14405 ice_vx += accel;
14406 else if(odx < 0)
14407 ice_vx -= accel;
14408 if(ody > 0)
14409 ice_vy += accel;
14410 else if(ody < 0)
14411 ice_vy -= accel;
14412 }
14413 //Decelerate in non-pushed direction
14414 if(is_inair)
14415 decel = zinit.air_drag;
14416 if(decel)
14417 {
14418 if(ice_vx)
14419 {
14420 if(!odx && abs(ice_vx) < decel)
14421 ice_vx = 0;
14422 else if(ice_vx > 0 && odx <= 0)
14423 ice_vx -= decel;
14424 else if(ice_vx < 0 && odx >= 0)
14425 ice_vx += decel;
14426 }
14427 if(ice_vy)
14428 {
14429 if(!ody && abs(ice_vy) < decel)
14430 ice_vy = 0;
14431 else if(ice_vy > 0 && ody <= 0)
14432 ice_vy -= decel;
14433 else if(ice_vy < 0 && ody >= 0)
14434 ice_vy += decel;
14435 }
14436 }
14437 }
14438 zfix cap = zslongToFix(zc_max(1,abs(icecmb.attributes[2])));
14439 dx = ice_vx = vbound(ice_vx, -cap, cap);
14440 dy = ice_vy = vbound(ice_vy, -cap, cap);
14441 if(!dx && !dy)
14442 ice_entry_count = 0;
14443 }
14444 250467 void HeroClass::mod_steps(std::vector<zfix*>& v)
14445 {
14446
2/4
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250467 times.
✗ Branch 3 not taken.
250467 bool can_combo = ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS);
14447
4/6
✓ Branch 0 taken 21068 times.
✓ Branch 1 taken 229399 times.
✓ Branch 2 taken 21068 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21068 times.
✗ Branch 5 not taken.
479866 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1) && can_combo) ||
14448
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 229399 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
229399 (isSideViewHero() && (on_sideview_solid_oldpos(this)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1));
14449 //!DIMITODO: add QR for slow combos under hero
14450
4/4
✓ Branch 0 taken 229399 times.
✓ Branch 1 taken 21068 times.
✓ Branch 2 taken 21068 times.
✓ Branch 3 taken 42136 times.
292603 if(slowcombo) for (int32_t i = 0; i <= 1; ++i)
14451 {
14452
2/2
✓ Branch 0 taken 956 times.
✓ Branch 1 taken 41180 times.
42136 if(tmpscr2[i].valid!=0)
14453 {
14454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41180 times.
41180 if (get_qr(qr_OLD_BRIDGE_COMBOS))
14455 {
14456 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i])))
14457 {
14458 slowcombo = false;
14459 break;
14460 }
14461 }
14462 else
14463 {
14464
2/4
✓ Branch 0 taken 41180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41180 times.
✗ Branch 3 not taken.
41180 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i])))
14465 {
14466 slowcombo = false;
14467 break;
14468 }
14469 }
14470 41180 }
14471 63204 }
14472
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
14473 250467 bool is_swimming = (action == swimming);
14474 250467 int32_t shieldid = getCurrentActiveShield();
14475
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 if(shieldid > -1)
14476 {
14477 itemdata const& shield = itemsbuf[shieldid];
14478 if(shield.flags & ITEM_FLAG10) //Change Speed flag
14479 {
14480 zfix perc = shield.misc7;
14481 perc /= 100;
14482 if(perc < 0)
14483 perc = (perc*-1)+1;
14484 zfix add(shield.misc8);
14485 add /= 100;
14486 for(zfix* stp : v)
14487 {
14488 zfix& pix = *stp;
14489 pix = (pix * perc) + add;
14490 }
14491 }
14492 }
14493
14494 250467 auto slow_cpos = COMBOPOS(x+7,y+8);
14495
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250467 times.
✓ Branch 2 taken 250256 times.
✓ Branch 3 taken 1753058 times.
2003314 if(can_combo) for(int q = 6; q >= 0; --q)
14496 {
14497 1753058 mapscr* m = FFCore.tempScreens[q];
14498
2/2
✓ Branch 0 taken 851124 times.
✓ Branch 1 taken 901934 times.
1753058 if(!m->valid) continue;
14499 851124 newcombo const& cmb = combobuf[m->data[slow_cpos]];
14500
14501
2/6
✓ Branch 0 taken 851124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 851124 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
851124 if (cmb.speed_mult != 1 || cmb.speed_div || cmb.speed_add)
14502 {
14503
2/2
✓ Branch 0 taken 4255620 times.
✓ Branch 1 taken 851124 times.
5106744 for(zfix* stp : v)
14504 {
14505 4255620 zfix& pix = *stp;
14506 4255620 pix *= cmb.speed_mult;
14507
1/2
✓ Branch 0 taken 4255620 times.
✗ Branch 1 not taken.
4255620 if(cmb.speed_div)
14508 4255620 pix /= cmb.speed_div;
14509 4255620 pix += cmb.speed_add;
14510 }
14511 851124 }
14512
4/4
✓ Branch 0 taken 600868 times.
✓ Branch 1 taken 250256 times.
✓ Branch 2 taken 600657 times.
✓ Branch 3 taken 211 times.
851124 if(q > 0 && cmb.type == cBRIDGE)
14513 {
14514
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
211 if(get_qr(qr_OLD_BRIDGE_COMBOS)
14515 ? !_walkflag_layer(x+7,y+8,1,&(tmpscr2[q-1]))
14516 211 : _effectflag_layer(x+7,y+8,1,&(tmpscr2[q-1])))
14517 {
14518 211 break; //Bridge blocks speed change from below it
14519 }
14520 }
14521 1101380 }
14522 250467 zfix mult = 1, div = 1;
14523
2/2
✓ Branch 0 taken 6290 times.
✓ Branch 1 taken 244177 times.
250467 if(is_swimming)
14524 {
14525 6290 mult = game->swim_mult;
14526 6290 div = game->swim_div;
14527 6290 }
14528
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 244177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
244177 else if(slowcharging && slowcombo) //1/2 speed
14529 {
14530 div = 2;
14531 }
14532
3/4
✓ Branch 0 taken 244177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21068 times.
✓ Branch 3 taken 223109 times.
244177 else if(slowcharging || slowcombo) //2/3 speed
14533 {
14534 21068 mult = 2;
14535 21068 div = 3;
14536 21068 }
14537
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 if(!div) div = 1;
14538
3/4
✓ Branch 0 taken 223109 times.
✓ Branch 1 taken 27358 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 223109 times.
250467 if(mult != 1 || div != 1)
14539 {
14540
2/2
✓ Branch 0 taken 136790 times.
✓ Branch 1 taken 27358 times.
164148 for(zfix* stp : v)
14541 {
14542 136790 zfix& pix = *stp;
14543 136790 pix = ((pix / div) * mult);
14544 }
14545 27358 }
14546 250467 }
14547
14548 13178853 void HeroClass::moveheroOld()
14549 {
14550
4/4
✓ Branch 0 taken 13163688 times.
✓ Branch 1 taken 15165 times.
✓ Branch 2 taken 14910 times.
✓ Branch 3 taken 13177638 times.
13178853 if(lstunclock || is_conveyor_stunned) return;
14551 13177638 int32_t xoff=x.getInt()&7;
14552 13177638 int32_t yoff=y.getInt()&7;
14553
4/4
✓ Branch 0 taken 13010750 times.
✓ Branch 1 taken 166888 times.
✓ Branch 2 taken 23324 times.
✓ Branch 3 taken 13034074 times.
13177638 if(NO_GRIDLOCK)
14554 {
14555 190212 xoff = 0;
14556 190212 yoff = 0;
14557 190212 }
14558 13187012 int32_t push=pushing;
14559 13187012 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
14560 13187012 pushing=0;
14561 13187012 zfix temp_step(hero_newstep);
14562 13187012 zfix temp_x(x);
14563 13187012 zfix temp_y(y);
14564
14565 13187012 int32_t flippers_id = current_item_id(itype_flippers);
14566 13187012 itemdata const& itm = itemsbuf[flippers_id];
14567 13187012 byte intbtn = byte(itm.misc3&0xFF);
14568 13187012 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
14569 13187012 bool eatdive = false;
14570
2/2
✓ Branch 0 taken 37658 times.
✓ Branch 1 taken 13149354 times.
13187012 if(diveclk>0)
14571 {
14572
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37658 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37658 if (isSideViewHero() && get_qr(qr_SIDESWIM)) diveclk = 0;
14573 37658 --diveclk;
14574
4/8
✓ Branch 0 taken 9502 times.
✓ Branch 1 taken 28156 times.
✓ Branch 2 taken 9502 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9502 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
37658 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && dive_pressed) //Cancellable Diving -V
14575 {
14576 diveclk = itemsbuf[flippers_id].misc2;
14577 eatdive = true;
14578 }
14579 37658 }
14580
4/4
✓ Branch 0 taken 113504 times.
✓ Branch 1 taken 13035850 times.
✓ Branch 2 taken 113277 times.
✓ Branch 3 taken 227 times.
13149354 else if(action == swimming && dive_pressed)
14581 {
14582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
14583 227 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
14584
14585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 if(global_diving==screen_diving)
14586 {
14587
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
14588 227 eatdive = true;
14589 227 }
14590 227 }
14591
2/2
✓ Branch 0 taken 13186785 times.
✓ Branch 1 taken 227 times.
13187012 if(eatdive)
14592 227 getIntBtnInput(intbtn, true, true, false, false, false);
14593
14594
2/2
✓ Branch 0 taken 13073862 times.
✓ Branch 1 taken 113150 times.
13187012 if(action==rafting)
14595 {
14596 113150 do_rafting();
14597
14598
2/2
✓ Branch 0 taken 112795 times.
✓ Branch 1 taken 355 times.
113150 if(action==rafting)
14599 {
14600 112795 return;
14601 }
14602
14603
14604 355 set_respawn_point();
14605 355 trySideviewLadder();
14606 355 }
14607
14608 13074217 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
14609 13074217 int32_t btnwpn = -1;
14610
14611 //&0xFFF removes the "bow & arrows" bitmask
14612 //The Quick Sword is allowed to interrupt attacks.
14613
4/4
✓ Branch 0 taken 12899383 times.
✓ Branch 1 taken 174834 times.
✓ Branch 2 taken 8706307 times.
✓ Branch 3 taken 4193076 times.
13074217 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
14614
8/8
✓ Branch 0 taken 11450709 times.
✓ Branch 1 taken 1623508 times.
✓ Branch 2 taken 11439410 times.
✓ Branch 3 taken 11299 times.
✓ Branch 4 taken 390074 times.
✓ Branch 5 taken 1244733 times.
✓ Branch 6 taken 72183 times.
✓ Branch 7 taken 1562624 times.
13074217 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
14615 {
14616
2/2
✓ Branch 0 taken 28963 times.
✓ Branch 1 taken 11482630 times.
11511593 if(DrunkrBbtn())
14617 {
14618 28963 btnwpn=getItemFamily(itemsbuf,Bwpn);
14619
2/2
✓ Branch 0 taken 28754 times.
✓ Branch 1 taken 209 times.
28963 dowpn = NEG_OR_MASK(Bwpn,0xFFF);
14620 28963 directWpn = directItemB;
14621 28963 }
14622
2/2
✓ Branch 0 taken 89240 times.
✓ Branch 1 taken 11393390 times.
11482630 else if(DrunkrAbtn())
14623 {
14624 89240 btnwpn=getItemFamily(itemsbuf,Awpn);
14625
2/2
✓ Branch 0 taken 86565 times.
✓ Branch 1 taken 2675 times.
89240 dowpn = NEG_OR_MASK(Awpn,0xFFF);
14626 89240 directWpn = directItemA;
14627 89240 }
14628
4/4
✓ Branch 0 taken 150132 times.
✓ Branch 1 taken 11243258 times.
✓ Branch 2 taken 150076 times.
✓ Branch 3 taken 56 times.
11393390 else if(get_qr(qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
14629 {
14630 56 btnwpn=getItemFamily(itemsbuf,Xwpn);
14631
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 dowpn = NEG_OR_MASK(Xwpn,0xFFF);
14632 56 directWpn = directItemX;
14633 56 }
14634
4/4
✓ Branch 0 taken 150076 times.
✓ Branch 1 taken 11243258 times.
✓ Branch 2 taken 149953 times.
✓ Branch 3 taken 123 times.
11393334 else if(get_qr(qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
14635 {
14636 123 btnwpn=getItemFamily(itemsbuf,Ywpn);
14637
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 dowpn = NEG_OR_MASK(Ywpn,0xFFF);
14638 123 directWpn = directItemY;
14639 123 }
14640
14641
1/2
✓ Branch 0 taken 11511593 times.
✗ Branch 1 not taken.
11511593 if(directWpn >= MAXITEMS) directWpn = -1;
14642
14643 // The Quick Sword only allows repeated sword or wand swings.
14644
7/8
✓ Branch 0 taken 11439410 times.
✓ Branch 1 taken 72183 times.
✓ Branch 2 taken 72183 times.
✓ Branch 3 taken 11439410 times.
✓ Branch 4 taken 71496 times.
✓ Branch 5 taken 687 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 11440097 times.
11511593 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
14645 71496 btnwpn=-1;
14646 11511593 }
14647
14648
2/2
✓ Branch 0 taken 4339390 times.
✓ Branch 1 taken 8734827 times.
13074217 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
14649
11/12
✓ Branch 0 taken 12241200 times.
✓ Branch 1 taken 833017 times.
✓ Branch 2 taken 11678987 times.
✓ Branch 3 taken 562213 times.
✓ Branch 4 taken 8089565 times.
✓ Branch 5 taken 3589422 times.
✓ Branch 6 taken 8030453 times.
✓ Branch 7 taken 59112 times.
✓ Branch 8 taken 85908 times.
✓ Branch 9 taken 7944545 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 85908 times.
13074217 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
14650 {
14651
2/2
✓ Branch 0 taken 3220 times.
✓ Branch 1 taken 82688 times.
85908 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
14652
5/6
✓ Branch 0 taken 85906 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 85891 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
85908 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
14653 {
14654
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 85891 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
85891 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
14655 {
14656 paymagiccost(attackid,true);
14657 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
14658 }
14659 85891 SetAttack();
14660 85891 attack=wSword;
14661
14662 85891 attackclk=0;
14663
2/2
✓ Branch 0 taken 82688 times.
✓ Branch 1 taken 3203 times.
85891 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
14664
14665
7/10
✓ Branch 0 taken 85891 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 524 times.
✓ Branch 3 taken 85367 times.
✓ Branch 4 taken 524 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 517 times.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
85891 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
14666 {
14667
1/2
✓ Branch 0 taken 517 times.
✗ Branch 1 not taken.
517 if(!checkmagiccost(dowpn))
14668 {
14669 item_error();
14670 }
14671 else
14672 {
14673 //clear the item script stack for a new script
14674 517 int i = dowpn;
14675 517 FFCore.reset_script_engine_data(ScriptType::Item, i);
14676 517 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
14677 517 did_scripta=true;
14678 }
14679 517 }
14680 85891 }
14681 else
14682 {
14683 17 item_error();
14684 }
14685 85908 }
14686 else
14687 {
14688 12988309 did_scripta=false;
14689 }
14690
14691
6/10
✓ Branch 0 taken 12924008 times.
✓ Branch 1 taken 150209 times.
✓ Branch 2 taken 12924008 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12924008 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12924008 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 12924008 times.
13074217 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
14692 {
14693
3/4
✓ Branch 0 taken 2286503 times.
✓ Branch 1 taken 10637505 times.
✓ Branch 2 taken 2286503 times.
✗ Branch 3 not taken.
12924008 if(DrunkUp() && canSideviewLadder())
14694 {
14695 setOnSideviewLadder(true);
14696 }
14697
3/4
✓ Branch 0 taken 1979673 times.
✓ Branch 1 taken 10944335 times.
✓ Branch 2 taken 1979673 times.
✗ Branch 3 not taken.
12924008 else if(DrunkDown() && canSideviewLadder(true))
14698 {
14699 y+=1;
14700 old_y += 1;
14701 setOnSideviewLadder(true);
14702 }
14703 12924008 }
14704
14705 13074217 int32_t wx=x;
14706 13074217 int32_t wy=y;
14707
3/6
✓ Branch 0 taken 9001520 times.
✓ Branch 1 taken 4072697 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13074217 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13074217 if((action==none || action==walking) && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
14708 {
14709 if((xoff==0)||diagonalMovement)
14710 {
14711 if(DrunkUp()) dir=up;
14712 if(DrunkDown()) dir=down;
14713 }
14714
14715 if((yoff==0)||diagonalMovement)
14716 {
14717 if(DrunkLeft()) dir=left;
14718 if(DrunkRight()) dir=right;
14719 }
14720 }
14721
14722
5/5
✓ Branch 0 taken 23324 times.
✓ Branch 1 taken 3082848 times.
✓ Branch 2 taken 2642820 times.
✓ Branch 3 taken 3529973 times.
✓ Branch 4 taken 3795252 times.
13074217 switch(dir)
14723 {
14724 case up:
14725 3082848 wy-=16;
14726 3082848 break;
14727
14728 case down:
14729 2642820 wy+=16;
14730 2642820 break;
14731
14732 case left:
14733 3529973 wx-=16;
14734 3529973 break;
14735
14736 case right:
14737 3795252 wx+=16;
14738 3795252 break;
14739 }
14740
14741 13074217 do_lens();
14742
14743 13074217 WalkflagInfo info;
14744
14745 13074217 bool no_jinx = true;
14746
6/8
✓ Branch 0 taken 12241200 times.
✓ Branch 1 taken 786369 times.
✓ Branch 2 taken 28398 times.
✓ Branch 3 taken 12212802 times.
✓ Branch 4 taken 28398 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 28398 times.
13074217 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
14747 {
14748 28398 bool paidmagic = false;
14749
1/2
✓ Branch 0 taken 28398 times.
✗ Branch 1 not taken.
28398 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
14750
6/10
✓ Branch 0 taken 28398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26613 times.
✓ Branch 3 taken 1785 times.
✓ Branch 4 taken 1785 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1785 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1785 times.
28398 if(!liftonly && btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
14751 {
14752
1/2
✓ Branch 0 taken 1785 times.
✗ Branch 1 not taken.
1785 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
14753 1785 no_jinx = checkitem_jinx(attackid);
14754
4/8
✓ Branch 0 taken 1784 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1784 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1784 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1785 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
14755 {
14756
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1784 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
14757 paymagiccost(attackid,true);
14758 misc_internal_hero_flags |= LF_PAID_WAND_COST;
14759 }
14760 1784 SetAttack();
14761 1784 attack=wWand;
14762 1784 attackclk=0;
14763 1784 }
14764 else
14765 {
14766 1 item_error();
14767 }
14768 1785 }
14769
5/8
✓ Branch 0 taken 26613 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2255 times.
✓ Branch 3 taken 24358 times.
✓ Branch 4 taken 2255 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2255 times.
28868 else if(!liftonly && (btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
14770
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2255 times.
✓ Branch 2 taken 2255 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2255 times.
2255 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
14771 {
14772 2255 no_jinx = checkitem_jinx(dowpn);
14773
3/6
✓ Branch 0 taken 2255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2255 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2255 times.
2255 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
14774 {
14775 item_error();
14776 }
14777 else
14778 {
14779 2255 paymagiccost(dowpn);
14780 2255 paidmagic = true;
14781 2255 SetAttack();
14782 2255 attack=wHammer;
14783
1/2
✓ Branch 0 taken 2255 times.
✗ Branch 1 not taken.
2255 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
14784 2255 attackclk=0;
14785 }
14786 2255 }
14787
5/8
✓ Branch 0 taken 24358 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1830 times.
✓ Branch 3 taken 22528 times.
✓ Branch 4 taken 1830 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1830 times.
26188 else if(!liftonly && (btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
14788
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1830 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1830 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1830 times.
1830 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
14789 {
14790 //checkbunny handled where magic cost is paid
14791
1/2
✓ Branch 0 taken 1830 times.
✗ Branch 1 not taken.
1830 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
14792 1830 no_jinx = checkitem_jinx(attackid);
14793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1830 times.
1830 if(no_jinx)
14794 {
14795 1830 SetAttack();
14796 1830 attack=wFire;
14797 1830 attackclk=0;
14798 1830 }
14799 1830 }
14800
5/8
✓ Branch 0 taken 22528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 22524 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
22532 else if(!liftonly && (btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
14801
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
14802 {
14803
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
14804 4 no_jinx = checkitem_jinx(attackid);
14805
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
14806 {
14807
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
14808 paymagiccost(attackid,true);
14809 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
14810 }
14811 4 SetAttack();
14812 4 attack=wCByrna;
14813 4 attackclk=0;
14814 4 }
14815 else
14816 {
14817 item_error();
14818 }
14819 4 }
14820
2/8
✓ Branch 0 taken 22524 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22524 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
22524 else if(!liftonly && (btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
14821 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
14822 {
14823 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
14824 no_jinx = checkitem_jinx(attackid);
14825 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
14826 {
14827 paymagiccost(attackid);
14828 SetAttack();
14829 attack = wBugNet;
14830 attackclk = 0;
14831 sfx(itemsbuf[attackid].usesound);
14832 }
14833 else
14834 {
14835 item_error();
14836 }
14837 }
14838 else
14839 {
14840
1/2
✓ Branch 0 taken 22524 times.
✗ Branch 1 not taken.
22524 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
14841 22524 no_jinx = checkitem_jinx(itmid);
14842
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 22473 times.
22524 if(no_jinx)
14843 {
14844 22473 paidmagic = startwpn(itmid);
14845
14846
2/2
✓ Branch 0 taken 19418 times.
✓ Branch 1 taken 3055 times.
22473 if(paidmagic)
14847 {
14848
6/10
✓ Branch 0 taken 19398 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 19398 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19398 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 19398 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 19398 times.
19418 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
14849 {
14850 ;
14851 20 }
14852 else
14853 {
14854 19398 SetAttack();
14855 19398 attackclk=0;
14856 19398 attack=none;
14857
14858
2/2
✓ Branch 0 taken 5913 times.
✓ Branch 1 taken 13485 times.
19398 if(btnwpn==itype_brang)
14859 {
14860 13485 attack=wBrang;
14861 13485 }
14862 }
14863 19418 }
14864 else
14865 {
14866 // Weapon not started: directWpn should be reset to prev. value.
14867 3055 directWpn = olddirectwpn;
14868 }
14869 22473 }
14870 }
14871
14872
8/12
✓ Branch 0 taken 28398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28346 times.
✓ Branch 3 taken 52 times.
✓ Branch 4 taken 1211 times.
✓ Branch 5 taken 27135 times.
✓ Branch 6 taken 1145 times.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1145 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
28398 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
14873 {
14874
3/4
✓ Branch 0 taken 1143 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1145 times.
1145 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
14875 {
14876 item_error();
14877 }
14878 else
14879 {
14880 // Only charge for magic if item's magic cost wasn't already charged
14881 // for the item's main use.
14882
4/4
✓ Branch 0 taken 1143 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1136 times.
1145 if(!paidmagic && attack!=wWand)
14883 1136 paymagiccost(dowpn);
14884 //clear the item script stack for a new script
14885 1145 int i = dowpn;
14886 1145 FFCore.reset_script_engine_data(ScriptType::Item, i);
14887 1145 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
14888 1145 did_scriptb=true;
14889 }
14890 1145 }
14891
14892
8/12
✓ Branch 0 taken 28346 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 28326 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 28326 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 28326 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28326 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 28326 times.
28398 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
14893 {
14894 20 return;
14895 }
14896
2/2
✓ Branch 0 taken 28326 times.
✓ Branch 1 taken 52 times.
28378 if(!no_jinx)
14897 52 did_scriptb = false;
14898 28378 }
14899 else
14900 {
14901 12999171 did_scriptb=false;
14902 }
14903
14904
6/6
✓ Branch 0 taken 11451375 times.
✓ Branch 1 taken 1576174 times.
✓ Branch 2 taken 11328792 times.
✓ Branch 3 taken 122583 times.
✓ Branch 4 taken 23324 times.
✓ Branch 5 taken 11351156 times.
13027549 if(attackclk || action==attacking || action==sideswimattacking)
14905 {
14906
14907
4/8
✓ Branch 0 taken 122583 times.
✓ Branch 1 taken 1599498 times.
✓ Branch 2 taken 122583 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 122583 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1722081 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
14908 {
14909 if((xoff==0)||diagonalMovement)
14910 {
14911 if(DrunkUp()) dir=up;
14912 if(DrunkDown()) dir=down;
14913 }
14914
14915 if((yoff==0)||diagonalMovement)
14916 {
14917 if(DrunkLeft()) dir=left;
14918 if(DrunkRight()) dir=right;
14919 }
14920 }
14921
14922 1722081 bool attacked = doattack();
14923
14924 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
14925
10/12
✓ Branch 0 taken 1718936 times.
✓ Branch 1 taken 3145 times.
✓ Branch 2 taken 1238425 times.
✓ Branch 3 taken 480511 times.
✓ Branch 4 taken 264775 times.
✓ Branch 5 taken 973650 times.
✓ Branch 6 taken 229126 times.
✓ Branch 7 taken 35649 times.
✓ Branch 8 taken 229126 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 229126 times.
1722081 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
14926 {
14927
4/4
✓ Branch 0 taken 110499 times.
✓ Branch 1 taken 118627 times.
✓ Branch 2 taken 37654 times.
✓ Branch 3 taken 72845 times.
229126 if((xoff==0)||diagonalMovement)
14928 {
14929
2/2
✓ Branch 0 taken 139895 times.
✓ Branch 1 taken 16386 times.
156281 if(DrunkUp()) dir=up;
14930
14931
2/2
✓ Branch 0 taken 136900 times.
✓ Branch 1 taken 19381 times.
156281 if(DrunkDown()) dir=down;
14932 156281 }
14933
14934
4/4
✓ Branch 0 taken 87801 times.
✓ Branch 1 taken 141325 times.
✓ Branch 2 taken 35649 times.
✓ Branch 3 taken 52152 times.
229126 if((yoff==0)||diagonalMovement)
14935 {
14936
2/2
✓ Branch 0 taken 151630 times.
✓ Branch 1 taken 25344 times.
176974 if(DrunkLeft()) dir=left;
14937
14938
2/2
✓ Branch 0 taken 150791 times.
✓ Branch 1 taken 26183 times.
176974 if(DrunkRight()) dir=right;
14939 176974 }
14940 229126 }
14941
14942
9/10
✓ Branch 0 taken 1606550 times.
✓ Branch 1 taken 115531 times.
✓ Branch 2 taken 1565564 times.
✓ Branch 3 taken 40986 times.
✓ Branch 4 taken 1565129 times.
✓ Branch 5 taken 435 times.
✓ Branch 6 taken 1560767 times.
✓ Branch 7 taken 4362 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1560767 times.
1722081 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
14943 {
14944 1560767 return;
14945 }
14946
2/2
✓ Branch 0 taken 45783 times.
✓ Branch 1 taken 115531 times.
161314 else if(!attacked)
14947 {
14948 // Spin attack - change direction
14949
3/4
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 114866 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 665 times.
115531 if(spins>1 && attack != wHammer)
14950 {
14951 665 spins--;
14952
14953
2/2
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 45 times.
665 if(spins%5==0)
14954 {
14955
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
14956 45 sfx(itemsbuf[id].usesound,pan(x.getInt()));
14957 45 }
14958 665 attackclk=1;
14959
14960
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 166 times.
✓ Branch 4 taken 166 times.
665 switch(dir)
14961 {
14962 case up:
14963 167 dir=left;
14964 167 break;
14965
14966 case right:
14967 166 dir=up;
14968 166 break;
14969
14970 case down:
14971 166 dir=right;
14972 166 break;
14973
14974 case left:
14975 166 dir=down;
14976 166 break;
14977 }
14978
14979 665 return;
14980 }
14981 else
14982 {
14983 114866 spins=0;
14984 }
14985
14986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114866 times.
114866 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
14987 114866 else {action=none; FFCore.setHeroAction(none);}
14988 114866 attackclk=0;
14989 114866 charging=0;
14990 114866 }
14991 160649 }
14992
14993
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 11511739 times.
11511805 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
14994 66 return;
14995
14996
2/2
✓ Branch 0 taken 4326261 times.
✓ Branch 1 taken 7185478 times.
11511739 if(action==walking) //still walking
14997 {
14998
9/10
✓ Branch 0 taken 5278422 times.
✓ Branch 1 taken 1907056 times.
✓ Branch 2 taken 3675409 times.
✓ Branch 3 taken 1603013 times.
✓ Branch 4 taken 1935316 times.
✓ Branch 5 taken 1740093 times.
✓ Branch 6 taken 79677 times.
✓ Branch 7 taken 1855639 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79677 times.
7185478 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
14999 {
15000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79677 times.
79677 if(attackclk>0) SetAttack();
15001 79677 else {action = none; FFCore.setHeroAction(none);}
15002 79677 hero_count=-1;
15003 79677 return;
15004 }
15005
15006 7105801 autostep=false;
15007
15008
4/6
✓ Branch 0 taken 4948862 times.
✓ Branch 1 taken 2156939 times.
✓ Branch 2 taken 4948862 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4948862 times.
7105801 if(!(diagonalMovement || NO_GRIDLOCK))
15009 {
15010
2/4
✓ Branch 0 taken 4948862 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4948862 times.
4948862 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15011 {
15012 if(dir==up&&yoff)
15013 {
15014 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
15015 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
15016 execute(info);
15017
15018 if(!info.isUnwalkable())
15019 {
15020 moveOld2(up);
15021 }
15022 else
15023 {
15024 action=none; FFCore.setHeroAction(none);
15025 }
15026
15027 return;
15028 }
15029
15030 if(dir==down&&yoff)
15031 {
15032 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
15033 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
15034 execute(info);
15035
15036 if(!info.isUnwalkable())
15037 {
15038 moveOld2(down);
15039 }
15040 else
15041 {
15042 action=none; FFCore.setHeroAction(none);
15043 }
15044
15045 return;
15046 }
15047
15048 if(dir==left&&xoff)
15049 {
15050 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
15051 execute(info);
15052
15053 if(!info.isUnwalkable())
15054 {
15055 moveOld2(left);
15056 }
15057 else
15058 {
15059 action=none; FFCore.setHeroAction(none);
15060 }
15061
15062 return;
15063 }
15064
15065 if(dir==right&&xoff)
15066 {
15067 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
15068 execute(info);
15069
15070 if(!info.isUnwalkable())
15071 {
15072 moveOld2(right);
15073 }
15074 else
15075 {
15076 action=none; FFCore.setHeroAction(none);
15077 }
15078
15079 return;
15080 }
15081 }
15082 else
15083 {
15084
4/4
✓ Branch 0 taken 1152561 times.
✓ Branch 1 taken 3796301 times.
✓ Branch 2 taken 188777 times.
✓ Branch 3 taken 963784 times.
4948862 if(dir==up&&yoff)
15085 {
15086 963784 while(true)
15087 {
15088 963786 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15089 963786 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
15090 963786 execute(info);
15091
15092
2/2
✓ Branch 0 taken 5173 times.
✓ Branch 1 taken 958613 times.
963786 if(!info.isUnwalkable())
15093 {
15094 958613 hero_newstep = temp_step;
15095 958613 x = temp_x;
15096 958613 y = temp_y;
15097 958613 moveOld2(up);
15098 958613 return;
15099 }
15100 //Could not move, try moving less
15101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5173 times.
5173 if(temp_y != int32_t(temp_y))
15102 {
15103 temp_y = floor((double)temp_y);
15104 continue;
15105 }
15106
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5171 times.
5173 else if(temp_step > 1)
15107 {
15108
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(temp_step != int32_t(temp_step)) //floor
15109 2 temp_step = floor((double)temp_step);
15110 else --temp_step;
15111 2 continue;
15112 }
15113 else //Can't move less, stop moving
15114 {
15115 5171 action=none; FFCore.setHeroAction(none);
15116 }
15117 5171 return;
15118 }
15119 }
15120
15121
4/4
✓ Branch 0 taken 945025 times.
✓ Branch 1 taken 3040053 times.
✓ Branch 2 taken 156232 times.
✓ Branch 3 taken 788793 times.
3985078 if(dir==down&&yoff)
15122 {
15123 788793 while(true)
15124 {
15125 788847 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
15126 788847 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
15127 788847 execute(info);
15128
15129
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 784392 times.
788847 if(!info.isUnwalkable())
15130 {
15131 784392 hero_newstep = temp_step;
15132 784392 x = temp_x;
15133 784392 y = temp_y;
15134 784392 moveOld2(down);
15135 784392 return;
15136 }
15137 //Could not move, try moving less
15138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4455 times.
4455 if(temp_y != int32_t(temp_y))
15139 {
15140 temp_y = floor((double)temp_y);
15141 continue;
15142 }
15143
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 4401 times.
4455 else if(temp_step > 1)
15144 {
15145
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(temp_step != int32_t(temp_step)) //floor
15146 54 temp_step = floor((double)temp_step);
15147 else --temp_step;
15148 54 continue;
15149 }
15150 else //Can't move less, stop moving
15151 {
15152 4401 action=none; FFCore.setHeroAction(none);
15153 }
15154 4401 return;
15155 }
15156 }
15157
15158
4/4
✓ Branch 0 taken 1387356 times.
✓ Branch 1 taken 1808929 times.
✓ Branch 2 taken 232475 times.
✓ Branch 3 taken 1154881 times.
3196285 if(dir==left&&xoff)
15159 {
15160 1154881 while(true)
15161 {
15162 1154881 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
15163 1154881 execute(info);
15164
15165
2/2
✓ Branch 0 taken 5165 times.
✓ Branch 1 taken 1149716 times.
1154881 if(!info.isUnwalkable())
15166 {
15167 1149716 hero_newstep = temp_step;
15168 1149716 x = temp_x;
15169 1149716 y = temp_y;
15170 1149716 moveOld2(left);
15171 1149716 return;
15172 }
15173 //Could not move, try moving less
15174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5165 times.
5165 if(temp_x != int32_t(temp_x))
15175 {
15176 temp_x = floor((double)temp_x);
15177 continue;
15178 }
15179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5165 times.
5165 else if(temp_step > 1)
15180 {
15181 if(temp_step != int32_t(temp_step)) //floor
15182 temp_step = floor((double)temp_step);
15183 else --temp_step;
15184 continue;
15185 }
15186 else //Can't move less, stop moving
15187 {
15188 5165 action=none; FFCore.setHeroAction(none);
15189 }
15190 5165 return;
15191 }
15192 }
15193
15194
4/4
✓ Branch 0 taken 1463920 times.
✓ Branch 1 taken 577484 times.
✓ Branch 2 taken 245282 times.
✓ Branch 3 taken 1218638 times.
2041404 if(dir==right&&xoff)
15195 {
15196 1218638 while(true)
15197 {
15198 1218700 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
15199 1218700 execute(info);
15200
15201
2/2
✓ Branch 0 taken 5827 times.
✓ Branch 1 taken 1212873 times.
1218700 if(!info.isUnwalkable())
15202 {
15203 1212873 hero_newstep = temp_step;
15204 1212873 x = temp_x;
15205 1212873 y = temp_y;
15206 1212873 moveOld2(right);
15207 1212873 return;
15208 }
15209 //Could not move, try moving less
15210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5827 times.
5827 if(temp_x != int32_t(temp_x))
15211 {
15212 temp_x = floor((double)temp_x);
15213 continue;
15214 }
15215
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 5765 times.
5827 else if(temp_step > 1)
15216 {
15217
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(temp_step != int32_t(temp_step)) //floor
15218 62 temp_step = floor((double)temp_step);
15219 else --temp_step;
15220 62 continue;
15221 }
15222 else //Can't move less, stop moving
15223 {
15224 5765 action=none; FFCore.setHeroAction(none);
15225 }
15226 5765 return;
15227 }
15228 }
15229 }
15230 822766 }
15231
15232 2979705 } // endif (action==walking)
15233
15234
16/24
✓ Branch 0 taken 7156717 times.
✓ Branch 1 taken 149249 times.
✓ Branch 2 taken 7156717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7156717 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7156717 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7156717 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7156717 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 7156717 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 7156717 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 7156717 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 7115731 times.
✓ Branch 19 taken 40986 times.
✓ Branch 20 taken 7115296 times.
✓ Branch 21 taken 435 times.
✓ Branch 22 taken 91081 times.
✓ Branch 23 taken 7024215 times.
7305966 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
15235 {
15236 7024215 action=none; FFCore.setHeroAction(none);
15237 7024215 }
15238
15239
2/2
✓ Branch 0 taken 3527734 times.
✓ Branch 1 taken 3778232 times.
7305966 if(diagonalMovement)
15240 {
15241
5/5
✓ Branch 0 taken 1137325 times.
✓ Branch 1 taken 532535 times.
✓ Branch 2 taken 441369 times.
✓ Branch 3 taken 677893 times.
✓ Branch 4 taken 738612 times.
3527734 switch(holddir)
15242 {
15243 case up:
15244
2/2
✓ Branch 0 taken 515898 times.
✓ Branch 1 taken 16637 times.
532535 if(!Up())
15245 {
15246 16637 holddir=-1;
15247 16637 }
15248
15249 532535 break;
15250
15251 case down:
15252
2/2
✓ Branch 0 taken 426551 times.
✓ Branch 1 taken 14818 times.
441369 if(!Down())
15253 {
15254 14818 holddir=-1;
15255 14818 }
15256
15257 441369 break;
15258
15259 case left:
15260
2/2
✓ Branch 0 taken 658114 times.
✓ Branch 1 taken 19779 times.
677893 if(!Left())
15261 {
15262 19779 holddir=-1;
15263 19779 }
15264
15265 677893 break;
15266
15267 case right:
15268
2/2
✓ Branch 0 taken 718171 times.
✓ Branch 1 taken 20441 times.
738612 if(!Right())
15269 {
15270 20441 holddir=-1;
15271 20441 }
15272
15273 738612 break;
15274
15275 default:
15276 1137325 break;
15277 } //end switch
15278
15279
4/4
✓ Branch 0 taken 2979440 times.
✓ Branch 1 taken 548294 times.
✓ Branch 2 taken 31652 times.
✓ Branch 3 taken 3010132 times.
3527734 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
15280 {
15281 579946 walkable = false;
15282
6/6
✓ Branch 0 taken 95415 times.
✓ Branch 1 taken 430515 times.
✓ Branch 2 taken 92341 times.
✓ Branch 3 taken 3074 times.
✓ Branch 4 taken 23327 times.
✓ Branch 5 taken 69014 times.
579946 if(DrunkUp()&&(holddir==-1||holddir==up))
15283 {
15284
5/8
✓ Branch 0 taken 3090 times.
✓ Branch 1 taken 68998 times.
✓ Branch 2 taken 3057 times.
✓ Branch 3 taken 33 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3090 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
72088 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
15285 {
15286 }
15287 else
15288 {
15289
5/10
✓ Branch 0 taken 71124 times.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 71124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71124 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 71124 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
72088 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
15290 {
15291 71124 dir=up;
15292 71124 }
15293
15294 72088 holddir=up;
15295
15296
4/4
✓ Branch 0 taken 9323 times.
✓ Branch 1 taken 62765 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 9321 times.
72088 if(DrunkRight()&&shiftdir!=left)
15297 {
15298 9321 shiftdir=right;
15299
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9321 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9321 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
15300
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9321 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9321 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
15301 9321 }
15302
4/4
✓ Branch 0 taken 8767 times.
✓ Branch 1 taken 54000 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8757 times.
62767 else if(DrunkLeft()&&shiftdir!=right)
15303 {
15304 8757 shiftdir=left;
15305
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8757 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
15306
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8757 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
15307 8757 }
15308 else
15309 {
15310 54010 shiftdir=-1;
15311 }
15312
15313 //walkable if Ladder can be placed or is already placed vertically
15314
1/18
✗ Branch 0 not taken.
✓ Branch 1 taken 72088 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
72088 if(isSideViewHero() && !toogam && !((can_deploy_ladder() && get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW)) || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15315 {
15316 walkable=false;
15317 }
15318 else
15319 {
15320
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 72088 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 72084 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
72088 if ((get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW) && can_deploy_ladder()) || (ladderx && laddery && ladderdir==up)) justmoved = 2; //Prevent the slope-snap code from running
15321 72088 do
15322 {
15323 83739 zfix ty = y - hero_newstep;
15324 167478 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15325 83739 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15326
15327
3/4
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 83449 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 290 times.
83739 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15328 {
15329 290 info = info || walkflag(x, 0_zf, 2, up);
15330 290 info = info || walkflag(x+15, 0_zf, 1, up);
15331 290 }
15332 83739 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15333
15334 83739 execute(info);
15335
15336
2/2
✓ Branch 0 taken 22302 times.
✓ Branch 1 taken 61437 times.
83739 if(info.isUnwalkable())
15337 {
15338
2/2
✓ Branch 0 taken 1000 times.
✓ Branch 1 taken 21302 times.
22302 if(y != y.getInt())
15339 {
15340 1000 y.doRound();
15341 1000 }
15342
2/2
✓ Branch 0 taken 10651 times.
✓ Branch 1 taken 10651 times.
21302 else if(hero_newstep > 1)
15343 {
15344
1/2
✓ Branch 0 taken 10651 times.
✗ Branch 1 not taken.
10651 if(hero_newstep != int32_t(hero_newstep)) //floor
15345 10651 hero_newstep = floor((double)hero_newstep);
15346 else --hero_newstep;
15347 10651 }
15348 else
15349 10651 break;
15350 11651 }
15351 61437 else walkable = true;
15352
2/2
✓ Branch 0 taken 11651 times.
✓ Branch 1 taken 61437 times.
73088 }
15353 73088 while(!walkable);
15354 }
15355
15356 72088 int32_t s=shiftdir;
15357
15358
5/6
✓ Branch 0 taken 3090 times.
✓ Branch 1 taken 68998 times.
✓ Branch 2 taken 3058 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 3090 times.
✗ Branch 5 not taken.
72088 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM))
15359 {
15360 shiftdir=-1;
15361 }
15362 else
15363 {
15364
2/2
✓ Branch 0 taken 8757 times.
✓ Branch 1 taken 63331 times.
72088 if(s==left)
15365 {
15366 8757 do
15367 {
15368 10187 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
15369
15370 10187 execute(info);
15371
15372
2/2
✓ Branch 0 taken 2733 times.
✓ Branch 1 taken 7454 times.
10187 if(info.isUnwalkable())
15373 {
15374
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 2606 times.
2733 if(x != x.getInt())
15375 {
15376 127 x.doRound();
15377 127 }
15378
2/2
✓ Branch 0 taken 1303 times.
✓ Branch 1 taken 1303 times.
2606 else if(hero_newstep_diag > 1)
15379 {
15380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
1303 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15381 1303 hero_newstep_diag.doFloor();
15382 else --hero_newstep_diag;
15383 1303 }
15384 else
15385 1303 shiftdir = -1;
15386 2733 }
15387
2/2
✓ Branch 0 taken 6121 times.
✓ Branch 1 taken 1333 times.
7454 else if(walkable)
15388 {
15389 6121 do
15390 {
15391 6151 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
15392 6151 execute(info);
15393
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6103 times.
6151 if(info.isUnwalkable())
15394 {
15395
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
48 if(x != x.getInt())
15396 {
15397 12 x.doRound();
15398 12 }
15399
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 18 times.
36 else if(hero_newstep_diag > 1)
15400 {
15401
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15402 18 hero_newstep_diag.doFloor();
15403 else --hero_newstep_diag;
15404 18 }
15405 else
15406 18 shiftdir = -1;
15407 48 }
15408 6103 else break;
15409
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 18 times.
48 }
15410 48 while(shiftdir != -1);
15411 6121 break;
15412 }
15413 1333 else break;
15414
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 1303 times.
2733 }
15415 2733 while(shiftdir != -1);
15416 8757 }
15417
2/2
✓ Branch 0 taken 54010 times.
✓ Branch 1 taken 9321 times.
63331 else if(s==right)
15418 {
15419 9321 do
15420 {
15421 10902 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
15422
15423 10902 execute(info);
15424
15425
2/2
✓ Branch 0 taken 3016 times.
✓ Branch 1 taken 7886 times.
10902 if(info.isUnwalkable())
15426 {
15427
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 2892 times.
3016 if(x != x.getInt())
15428 {
15429 124 x.doRound();
15430 124 }
15431
2/2
✓ Branch 0 taken 1457 times.
✓ Branch 1 taken 1435 times.
2892 else if(hero_newstep_diag > 1)
15432 {
15433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1457 times.
1457 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15434 1457 hero_newstep_diag.doFloor();
15435 else --hero_newstep_diag;
15436 1457 }
15437 else
15438 1435 shiftdir = -1;
15439 3016 }
15440
2/2
✓ Branch 0 taken 6588 times.
✓ Branch 1 taken 1298 times.
7886 else if(walkable)
15441 {
15442 6588 do
15443 {
15444 6610 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
15445 6610 execute(info);
15446
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 6574 times.
6610 if(info.isUnwalkable())
15447 {
15448
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 29 times.
36 if(x != x.getInt())
15449 {
15450 7 x.doRound();
15451 7 }
15452
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 14 times.
29 else if(hero_newstep_diag > 1)
15453 {
15454
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15455 15 hero_newstep_diag.doFloor();
15456 else --hero_newstep_diag;
15457 15 }
15458 else
15459 14 shiftdir = -1;
15460 36 }
15461 6574 else break;
15462
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 14 times.
36 }
15463 36 while(shiftdir != -1);
15464 6588 break;
15465 }
15466 1298 else break;
15467
2/2
✓ Branch 0 taken 1581 times.
✓ Branch 1 taken 1435 times.
3016 }
15468 3016 while(shiftdir != -1);
15469 9321 }
15470 }
15471
15472 72088 moveOld2(up);
15473 72088 shiftdir=s;
15474
15475
2/2
✓ Branch 0 taken 61437 times.
✓ Branch 1 taken 10651 times.
72088 if(!walkable)
15476 {
15477
2/2
✓ Branch 0 taken 3009 times.
✓ Branch 1 taken 7642 times.
10651 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15478 {
15479 7642 x = x.getInt();
15480 7642 y = y.getInt();
15481
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7642 times.
✓ Branch 4 taken 6058 times.
✓ Branch 5 taken 1584 times.
✓ Branch 6 taken 525 times.
✓ Branch 7 taken 7117 times.
9226 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15482
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1584 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1584 times.
✓ Branch 4 taken 1052 times.
✓ Branch 5 taken 532 times.
1584 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15483
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 532 times.
532 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15484 {
15485
7/12
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 513 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 513 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 513 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 513 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 525 times.
525 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
15486 525 sprite::move((zfix)-1,(zfix)0);
15487 525 }
15488 else
15489 {
15490
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7117 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7117 times.
✓ Branch 4 taken 1059 times.
✓ Branch 5 taken 6058 times.
✓ Branch 6 taken 583 times.
✓ Branch 7 taken 6534 times.
13175 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15491
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6058 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6058 times.
✓ Branch 4 taken 5475 times.
✓ Branch 5 taken 583 times.
6058 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15492
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 583 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 583 times.
583 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15493 {
15494
7/12
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 576 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 576 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 576 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 576 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 583 times.
583 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
15495 583 sprite::move((zfix)1,(zfix)0);
15496 583 }
15497 else
15498 {
15499 6534 pushing=push+1;
15500 }
15501 }
15502 7642 }
15503 else
15504 {
15505 3009 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15506 }
15507 10651 }
15508
15509 72088 return;
15510 }
15511 }
15512
15513
6/6
✓ Branch 0 taken 90059 times.
✓ Branch 1 taken 363783 times.
✓ Branch 2 taken 87053 times.
✓ Branch 3 taken 3006 times.
✓ Branch 4 taken 66542 times.
✓ Branch 5 taken 20511 times.
453842 if(DrunkDown()&&(holddir==-1||holddir==down))
15514 {
15515
4/8
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 66861 times.
✓ Branch 2 taken 2687 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2687 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
69548 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
15516 {
15517 }
15518 else
15519 {
15520
5/10
✓ Branch 0 taken 69344 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 69344 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 69344 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 69344 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
69548 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
15521 {
15522 69344 dir=down;
15523 69344 }
15524
15525 69548 holddir=down;
15526
15527
4/4
✓ Branch 0 taken 10006 times.
✓ Branch 1 taken 59542 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10000 times.
69548 if(DrunkRight()&&shiftdir!=left)
15528 {
15529 10000 shiftdir=right;
15530
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 10000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10000 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
15531
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10000 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
15532 10000 }
15533
4/4
✓ Branch 0 taken 10926 times.
✓ Branch 1 taken 48622 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 10918 times.
59548 else if(DrunkLeft()&&shiftdir!=right)
15534 {
15535 10918 shiftdir=left;
15536
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 10918 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10918 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
15537
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10918 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10918 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
15538 10918 }
15539 else
15540 {
15541 48630 shiftdir=-1;
15542 }
15543
15544 //bool walkable;
15545
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 69548 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
69548 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15546 {
15547 walkable=false;
15548 }
15549 else
15550 {
15551 69548 do
15552 {
15553 78914 info = walkflag(x,15+(y+hero_newstep),2,down);
15554
15555
2/2
✓ Branch 0 taken 47519 times.
✓ Branch 1 taken 31395 times.
78914 if(x.getFloor() & 7)
15556 47519 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
15557 else
15558 31395 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
15559
15560 78914 execute(info);
15561
15562
2/2
✓ Branch 0 taken 17711 times.
✓ Branch 1 taken 61203 times.
78914 if(info.isUnwalkable())
15563 {
15564
2/2
✓ Branch 0 taken 819 times.
✓ Branch 1 taken 16892 times.
17711 if(y != y.getInt())
15565 {
15566 819 y.doRound();
15567 819 }
15568
2/2
✓ Branch 0 taken 8547 times.
✓ Branch 1 taken 8345 times.
16892 else if(hero_newstep > 1)
15569 {
15570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8547 times.
8547 if(hero_newstep != int32_t(hero_newstep)) //floor
15571 8547 hero_newstep = floor((double)hero_newstep);
15572 else --hero_newstep;
15573 8547 }
15574 else
15575 8345 break;
15576 9366 }
15577 61203 else walkable = true;
15578
2/2
✓ Branch 0 taken 9366 times.
✓ Branch 1 taken 61203 times.
70569 }
15579 70569 while(!walkable);
15580 }
15581
15582 69548 int32_t s=shiftdir;
15583
15584
5/6
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 66861 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2687 times.
✗ Branch 5 not taken.
69548 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM))
15585 {
15586 shiftdir=-1;
15587 }
15588 else
15589 {
15590
2/2
✓ Branch 0 taken 10918 times.
✓ Branch 1 taken 58630 times.
69548 if(s==left)
15591 {
15592 10918 do
15593 {
15594 12477 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
15595
15596 12477 execute(info);
15597
15598
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 9543 times.
12477 if(info.isUnwalkable())
15599 {
15600
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 2750 times.
2934 if(x != x.getInt())
15601 {
15602 184 x.doRound();
15603 184 }
15604
2/2
✓ Branch 0 taken 1375 times.
✓ Branch 1 taken 1375 times.
2750 else if(hero_newstep_diag > 1)
15605 {
15606
1/2
✓ Branch 0 taken 1375 times.
✗ Branch 1 not taken.
1375 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15607 1375 hero_newstep_diag.doFloor();
15608 else --hero_newstep_diag;
15609 1375 }
15610 else
15611 1375 shiftdir = -1;
15612 2934 }
15613
2/2
✓ Branch 0 taken 7958 times.
✓ Branch 1 taken 1585 times.
9543 else if(walkable)
15614 {
15615 7958 do
15616 {
15617 7998 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
15618 7998 execute(info);
15619
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 7943 times.
7998 if(info.isUnwalkable())
15620 {
15621
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 30 times.
55 if(x != x.getInt())
15622 {
15623 25 x.doRound();
15624 25 }
15625
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
30 else if(hero_newstep_diag > 1)
15626 {
15627
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15628 15 hero_newstep_diag.doFloor();
15629 else --hero_newstep_diag;
15630 15 }
15631 else
15632 15 shiftdir = -1;
15633 55 }
15634 7943 else break;
15635
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 15 times.
55 }
15636 55 while(shiftdir != -1);
15637 7958 break;
15638 }
15639 1585 else break;
15640
2/2
✓ Branch 0 taken 1559 times.
✓ Branch 1 taken 1375 times.
2934 }
15641 2934 while(shiftdir != -1);
15642 10918 }
15643
2/2
✓ Branch 0 taken 48630 times.
✓ Branch 1 taken 10000 times.
58630 else if(s==right)
15644 {
15645 10000 do
15646 {
15647 11347 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
15648
15649 11347 execute(info);
15650
15651
2/2
✓ Branch 0 taken 2598 times.
✓ Branch 1 taken 8749 times.
11347 if(info.isUnwalkable())
15652 {
15653
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 2508 times.
2598 if(x != x.getInt())
15654 {
15655 90 x.doRound();
15656 90 }
15657
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 1251 times.
2508 else if(hero_newstep_diag > 1)
15658 {
15659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
1257 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15660 1257 hero_newstep_diag.doFloor();
15661 else --hero_newstep_diag;
15662 1257 }
15663 else
15664 1251 shiftdir = -1;
15665 2598 }
15666
2/2
✓ Branch 0 taken 7129 times.
✓ Branch 1 taken 1620 times.
8749 else if(walkable)
15667 {
15668 7129 do
15669 {
15670 7175 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
15671 7175 execute(info);
15672
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 7100 times.
7175 if(info.isUnwalkable())
15673 {
15674
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 58 times.
75 if(x != x.getInt())
15675 {
15676 17 x.doRound();
15677 17 }
15678
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 29 times.
58 else if(hero_newstep_diag > 1)
15679 {
15680
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15681 29 hero_newstep_diag.doFloor();
15682 else --hero_newstep_diag;
15683 29 }
15684 else
15685 29 shiftdir = -1;
15686 75 }
15687 7100 else break;
15688
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 29 times.
75 }
15689 75 while(shiftdir != -1);
15690 7129 break;
15691 }
15692 1620 else break;
15693
2/2
✓ Branch 0 taken 1347 times.
✓ Branch 1 taken 1251 times.
2598 }
15694 2598 while(shiftdir != -1);
15695 10000 }
15696 }
15697
15698 69548 moveOld2(down);
15699 69548 shiftdir=s;
15700
15701
2/2
✓ Branch 0 taken 61203 times.
✓ Branch 1 taken 8345 times.
69548 if(!walkable)
15702 {
15703
2/2
✓ Branch 0 taken 3466 times.
✓ Branch 1 taken 4879 times.
8345 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15704 {
15705 4879 x = x.getInt();
15706 4879 y = y.getInt();
15707
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4879 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4879 times.
✓ Branch 4 taken 3594 times.
✓ Branch 5 taken 1285 times.
✓ Branch 6 taken 520 times.
✓ Branch 7 taken 4359 times.
6164 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15708
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1285 times.
✓ Branch 4 taken 748 times.
✓ Branch 5 taken 537 times.
1285 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15709
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 537 times.
537 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15710 {
15711
9/12
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 516 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 516 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 512 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 512 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 520 times.
520 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
15712 520 sprite::move((zfix)-1,(zfix)0);
15713 520 }
15714
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4359 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4359 times.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 3594 times.
✓ Branch 6 taken 505 times.
✓ Branch 7 taken 3854 times.
7953 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15715
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3594 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3594 times.
✓ Branch 4 taken 3089 times.
✓ Branch 5 taken 505 times.
3594 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15716
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 505 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 505 times.
505 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15717 {
15718
7/12
✓ Branch 0 taken 499 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 499 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 499 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 499 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 499 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 505 times.
505 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
15719 505 sprite::move((zfix)1,(zfix)0);
15720 505 }
15721 else
15722 {
15723 3854 pushing=push+1;
15724 }
15725 4879 }
15726 else
15727 {
15728 3466 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15729 }
15730 8345 }
15731
15732 69548 return;
15733 }
15734 }
15735
15736
6/6
✓ Branch 0 taken 96690 times.
✓ Branch 1 taken 287604 times.
✓ Branch 2 taken 93311 times.
✓ Branch 3 taken 3379 times.
✓ Branch 4 taken 93209 times.
✓ Branch 5 taken 102 times.
384294 if(DrunkLeft()&&(holddir==-1||holddir==left))
15737 {
15738
5/8
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 93596 times.
✓ Branch 2 taken 2945 times.
✓ Branch 3 taken 47 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2992 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
96588 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
15739 {
15740 }
15741 else
15742 {
15743
4/6
✓ Branch 0 taken 96189 times.
✓ Branch 1 taken 399 times.
✓ Branch 2 taken 96189 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 96189 times.
96588 if(charging==0 && spins==0 && action != sideswimattacking)
15744 {
15745 96189 dir=left;
15746 96189 }
15747 96588 sideswimdir = left;
15748
15749 96588 holddir=left;
15750
15751
4/4
✓ Branch 0 taken 11718 times.
✓ Branch 1 taken 84870 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11717 times.
96588 if(DrunkUp()&&shiftdir!=down)
15752 {
15753 11717 shiftdir=up;
15754 11717 }
15755
4/4
✓ Branch 0 taken 10587 times.
✓ Branch 1 taken 74284 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 10584 times.
84871 else if(DrunkDown()&&shiftdir!=up)
15756 {
15757 10584 shiftdir=down;
15758 10584 }
15759 else
15760 {
15761 74287 shiftdir=-1;
15762 }
15763
15764 96588 do
15765 {
15766 106523 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
15767
15768 106523 info = info || walkflag(x-hero_newstep,y+15,1,left);
15769
15770 106523 execute(info);
15771
15772
2/2
✓ Branch 0 taken 19010 times.
✓ Branch 1 taken 87513 times.
106523 if(info.isUnwalkable())
15773 {
15774
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 18148 times.
19010 if(x != x.getInt())
15775 {
15776 862 x.doRound();
15777 862 }
15778
2/2
✓ Branch 0 taken 9073 times.
✓ Branch 1 taken 9075 times.
18148 else if(hero_newstep > 1)
15779 {
15780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9073 times.
9073 if(hero_newstep != int32_t(hero_newstep)) //floor
15781 9073 hero_newstep = floor((double)hero_newstep);
15782 else --hero_newstep;
15783 9073 }
15784 else
15785 9075 break;
15786 9935 }
15787 87513 else walkable = true;
15788
2/2
✓ Branch 0 taken 9935 times.
✓ Branch 1 taken 87513 times.
97448 }
15789 97448 while(!walkable);
15790
15791 96588 int32_t s=shiftdir;
15792
15793
10/14
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 93596 times.
✓ Branch 2 taken 2948 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 2992 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1341 times.
✓ Branch 7 taken 95247 times.
✓ Branch 8 taken 1341 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1341 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1341 times.
✗ Branch 13 not taken.
96588 if((isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15794 {
15795 1341 shiftdir=-1;
15796 1341 }
15797 else
15798 {
15799
2/2
✓ Branch 0 taken 83530 times.
✓ Branch 1 taken 11717 times.
95247 if(s==up)
15800 {
15801 11717 do
15802 {
15803 13347 zfix ty = y - hero_newstep_diag;
15804 26694 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15805 13347 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15806
15807
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13340 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
13347 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15808 {
15809 7 info = info || walkflag(x, 0_zf, 2, up);
15810 7 info = info || walkflag(x+15, 0_zf, 1, up);
15811 7 }
15812 13347 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15813
15814 13347 execute(info);
15815
15816
2/2
✓ Branch 0 taken 3067 times.
✓ Branch 1 taken 10280 times.
13347 if(info.isUnwalkable())
15817 {
15818
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 2874 times.
3067 if(y != y.getInt())
15819 {
15820 193 y.doRound();
15821 193 }
15822
2/2
✓ Branch 0 taken 1437 times.
✓ Branch 1 taken 1437 times.
2874 else if(hero_newstep_diag > 1)
15823 {
15824
1/2
✓ Branch 0 taken 1437 times.
✗ Branch 1 not taken.
1437 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15825 1437 hero_newstep_diag.doFloor();
15826 else --hero_newstep_diag;
15827 1437 }
15828 else
15829 1437 shiftdir = -1;
15830 3067 }
15831
2/2
✓ Branch 0 taken 8612 times.
✓ Branch 1 taken 1668 times.
10280 else if(walkable)
15832 {
15833 8612 do
15834 {
15835 8671 zfix tx = x-hero_newstep, ty = y-hero_newstep_diag;
15836 8671 info = walkflag(tx,(bigHitbox?0:8)+ty,1,up);
15837
15838
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8664 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
8671 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15839 {
15840 7 info = info || walkflag(tx, 0_zf, 1, up);
15841 7 info = info || walkflag(tx+15, 0_zf, 1, up);
15842 7 }
15843 8671 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
15844
15845 8671 execute(info);
15846
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 8574 times.
8671 if(info.isUnwalkable())
15847 {
15848
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 76 times.
97 if(y != y.getInt())
15849 {
15850 21 y.doRound();
15851 21 }
15852
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 38 times.
76 else if(hero_newstep_diag > 1)
15853 {
15854
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15855 38 hero_newstep_diag.doFloor();
15856 else --hero_newstep_diag;
15857 38 }
15858 else
15859 38 shiftdir = -1;
15860 97 }
15861 8574 else break;
15862
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 38 times.
97 }
15863 97 while(shiftdir != -1);
15864 8612 break;
15865 }
15866 1668 else break;
15867
2/2
✓ Branch 0 taken 1630 times.
✓ Branch 1 taken 1437 times.
3067 }
15868 3067 while(shiftdir != -1);
15869 11717 }
15870
2/2
✓ Branch 0 taken 72946 times.
✓ Branch 1 taken 10584 times.
83530 else if(s==down)
15871 {
15872 10584 do
15873 {
15874 12573 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
15875
15876 12573 execute(info);
15877
15878
2/2
✓ Branch 0 taken 3747 times.
✓ Branch 1 taken 8826 times.
12573 if(info.isUnwalkable())
15879 {
15880
2/2
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 3556 times.
3747 if(y != y.getInt())
15881 {
15882 191 y.doRound();
15883 191 }
15884
2/2
✓ Branch 0 taken 1798 times.
✓ Branch 1 taken 1758 times.
3556 else if(hero_newstep_diag > 1)
15885 {
15886
1/2
✓ Branch 0 taken 1798 times.
✗ Branch 1 not taken.
1798 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15887 1798 hero_newstep_diag.doFloor();
15888 else --hero_newstep_diag;
15889 1798 }
15890 else
15891 1758 shiftdir = -1;
15892 3747 }
15893
2/2
✓ Branch 0 taken 7293 times.
✓ Branch 1 taken 1533 times.
8826 else if(walkable)
15894 {
15895 7293 do
15896 {
15897 7309 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
15898 7309 execute(info);
15899
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7281 times.
7309 if(info.isUnwalkable())
15900 {
15901
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 24 times.
28 if(y != y.getInt())
15902 {
15903 4 y.doRound();
15904 4 }
15905
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 else if(hero_newstep_diag > 1)
15906 {
15907
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15908 12 hero_newstep_diag.doFloor();
15909 else --hero_newstep_diag;
15910 12 }
15911 else
15912 12 shiftdir = -1;
15913 28 }
15914 7281 else break;
15915
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 12 times.
28 }
15916 28 while(shiftdir != -1);
15917 7293 break;
15918 }
15919 1533 else break;
15920
2/2
✓ Branch 0 taken 1989 times.
✓ Branch 1 taken 1758 times.
3747 }
15921 3747 while(shiftdir != -1);
15922 10584 }
15923 }
15924
15925 96588 moveOld2(left);
15926 96588 shiftdir=s;
15927
15928
2/2
✓ Branch 0 taken 87513 times.
✓ Branch 1 taken 9075 times.
96588 if(!walkable)
15929 {
15930
2/2
✓ Branch 0 taken 3522 times.
✓ Branch 1 taken 5553 times.
9075 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15931 {
15932 5553 x = x.getInt();
15933 5553 y = y.getInt();
15934 5553 int32_t v1=bigHitbox?0:8;
15935 5553 int32_t v2=bigHitbox?8:12;
15936
15937
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 5553 times.
✓ Branch 2 taken 5553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4908 times.
✓ Branch 5 taken 645 times.
✓ Branch 6 taken 130 times.
✓ Branch 7 taken 5423 times.
6198 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15938
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 645 times.
✓ Branch 4 taken 514 times.
✓ Branch 5 taken 131 times.
645 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15939
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 131 times.
131 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15940 {
15941
9/12
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 123 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 120 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 120 times.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 130 times.
130 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
15942 130 sprite::move((zfix)0,(zfix)-1);
15943 130 }
15944
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 5423 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5423 times.
✓ Branch 4 taken 515 times.
✓ Branch 5 taken 4908 times.
✓ Branch 6 taken 138 times.
✓ Branch 7 taken 5285 times.
10331 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15945
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4908 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4908 times.
✓ Branch 4 taken 4770 times.
✓ Branch 5 taken 138 times.
4908 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15946
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 138 times.
138 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15947 {
15948
7/12
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 137 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 137 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 137 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 137 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 138 times.
138 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
15949 138 sprite::move((zfix)0,(zfix)1);
15950 138 }
15951 else
15952 {
15953 5285 pushing=push+1;
15954 }
15955 5553 }
15956 else
15957 {
15958 3522 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15959
15960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3522 times.
3522 if(action!=swimming)
15961 {
15962 3522 }
15963 }
15964 9075 }
15965
15966 96588 return;
15967 }
15968 }
15969
15970
5/6
✓ Branch 0 taken 99382 times.
✓ Branch 1 taken 188324 times.
✓ Branch 2 taken 95916 times.
✓ Branch 3 taken 3466 times.
✓ Branch 4 taken 95916 times.
✗ Branch 5 not taken.
287706 if(DrunkRight()&&(holddir==-1||holddir==right))
15971 {
15972
5/8
✓ Branch 0 taken 3423 times.
✓ Branch 1 taken 95959 times.
✓ Branch 2 taken 3321 times.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3423 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
99382 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
15973 {
15974 }
15975 else
15976 {
15977
4/6
✓ Branch 0 taken 98680 times.
✓ Branch 1 taken 702 times.
✓ Branch 2 taken 98680 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 98680 times.
99382 if(charging==0 && spins==0 && action != sideswimattacking)
15978 {
15979 98680 dir=right;
15980 98680 }
15981 99382 sideswimdir = right;
15982
15983 99382 holddir=right;
15984
15985
4/4
✓ Branch 0 taken 11581 times.
✓ Branch 1 taken 87801 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11580 times.
99382 if(DrunkUp()&&shiftdir!=down)
15986 {
15987 11580 shiftdir=up;
15988 11580 }
15989
4/4
✓ Branch 0 taken 9919 times.
✓ Branch 1 taken 77883 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 9915 times.
87802 else if(DrunkDown()&&shiftdir!=up)
15990 {
15991 9915 shiftdir=down;
15992 9915 }
15993 else
15994 {
15995 77887 shiftdir=-1;
15996 }
15997
15998 99382 do
15999 {
16000 110030 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
16001
16002 110030 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
16003
16004 110030 execute(info);
16005
16006
2/2
✓ Branch 0 taken 20331 times.
✓ Branch 1 taken 89699 times.
110030 if(info.isUnwalkable())
16007 {
16008
2/2
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 19562 times.
20331 if(x != x.getInt())
16009 {
16010 769 x.doRound();
16011 769 }
16012
2/2
✓ Branch 0 taken 9879 times.
✓ Branch 1 taken 9683 times.
19562 else if(hero_newstep > 1)
16013 {
16014
1/2
✓ Branch 0 taken 9879 times.
✗ Branch 1 not taken.
9879 if(hero_newstep != int32_t(hero_newstep)) //floor
16015 9879 hero_newstep = floor((double)hero_newstep);
16016 else --hero_newstep;
16017 9879 }
16018 else
16019 9683 break;
16020 10648 }
16021 89699 else walkable = true;
16022
2/2
✓ Branch 0 taken 10648 times.
✓ Branch 1 taken 89699 times.
100347 }
16023 100347 while(!walkable);
16024
16025 99382 int32_t s=shiftdir;
16026
16027
10/14
✓ Branch 0 taken 3423 times.
✓ Branch 1 taken 95959 times.
✓ Branch 2 taken 3373 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 3423 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2340 times.
✓ Branch 7 taken 97042 times.
✓ Branch 8 taken 2340 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2340 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2340 times.
✗ Branch 13 not taken.
99382 if((isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
16028 {
16029 2340 shiftdir=-1;
16030 2340 }
16031 else
16032 {
16033
2/2
✓ Branch 0 taken 85462 times.
✓ Branch 1 taken 11580 times.
97042 if(s==up)
16034 {
16035 11580 do
16036 {
16037 12921 zfix ty = y - hero_newstep_diag;
16038 25842 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
16039 12921 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
16040
16041
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 12913 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
12921 if (ty < 0 && !bigHitbox) //sanity check for up scroll
16042 {
16043 8 info = info || walkflag(x, 0_zf, 2, up);
16044 8 info = info || walkflag(x+15, 0_zf, 1, up);
16045 8 }
16046 12921 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
16047
16048 12921 execute(info);
16049
16050
2/2
✓ Branch 0 taken 2490 times.
✓ Branch 1 taken 10431 times.
12921 if(info.isUnwalkable())
16051 {
16052
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2298 times.
2490 if(y != y.getInt())
16053 {
16054 192 y.doRound();
16055 192 }
16056
2/2
✓ Branch 0 taken 1149 times.
✓ Branch 1 taken 1149 times.
2298 else if(hero_newstep_diag > 1)
16057 {
16058
1/2
✓ Branch 0 taken 1149 times.
✗ Branch 1 not taken.
1149 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
16059 1149 hero_newstep_diag.doFloor();
16060 else --hero_newstep_diag;
16061 1149 }
16062 else
16063 1149 shiftdir = -1;
16064 2490 }
16065
2/2
✓ Branch 0 taken 9125 times.
✓ Branch 1 taken 1306 times.
10431 else if(walkable)
16066 {
16067 9125 do
16068 {
16069 9173 zfix tx = x+hero_newstep, ty = y-hero_newstep_diag;
16070 9173 info = walkflag(tx+15,(bigHitbox?0:8)+ty,1,up);
16071
16072
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9167 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
9173 if (ty < 0 && !bigHitbox) //sanity check for up scroll
16073 {
16074 6 info = info || walkflag(tx, 0_zf, 1, up);
16075 6 info = info || walkflag(tx+15, 0_zf, 1, up);
16076 6 }
16077 9173 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
16078 9173 execute(info);
16079
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 9098 times.
9173 if(info.isUnwalkable())
16080 {
16081
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 54 times.
75 if(y != y.getInt())
16082 {
16083 21 y.doRound();
16084 21 }
16085
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
54 else if(hero_newstep_diag > 1)
16086 {
16087
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
16088 27 hero_newstep_diag.doFloor();
16089 else --hero_newstep_diag;
16090 27 }
16091 else
16092 27 shiftdir = -1;
16093 75 }
16094 9098 else break;
16095
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 27 times.
75 }
16096 75 while(shiftdir != -1);
16097 9125 break;
16098 }
16099 1306 else break;
16100
2/2
✓ Branch 0 taken 1341 times.
✓ Branch 1 taken 1149 times.
2490 }
16101 2490 while(shiftdir != -1);
16102 11580 }
16103
2/2
✓ Branch 0 taken 75547 times.
✓ Branch 1 taken 9915 times.
85462 else if(s==down)
16104 {
16105 9915 do
16106 {
16107 11620 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
16108
16109 11620 execute(info);
16110
16111
2/2
✓ Branch 0 taken 3167 times.
✓ Branch 1 taken 8453 times.
11620 if(info.isUnwalkable())
16112 {
16113
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 2966 times.
3167 if(y != y.getInt())
16114 {
16115 201 y.doRound();
16116 201 }
16117
2/2
✓ Branch 0 taken 1504 times.
✓ Branch 1 taken 1462 times.
2966 else if(hero_newstep_diag > 1)
16118 {
16119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1504 times.
1504 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
16120 1504 hero_newstep_diag.doFloor();
16121 else --hero_newstep_diag;
16122 1504 }
16123 else
16124 1462 shiftdir = -1;
16125 3167 }
16126
2/2
✓ Branch 0 taken 7115 times.
✓ Branch 1 taken 1338 times.
8453 else if(walkable)
16127 {
16128 7115 do
16129 {
16130 7148 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
16131 7148 execute(info);
16132
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 7094 times.
7148 if(info.isUnwalkable())
16133 {
16134
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 44 times.
54 if(y != y.getInt())
16135 {
16136 10 y.doRound();
16137 10 }
16138
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 21 times.
44 else if(hero_newstep_diag > 1)
16139 {
16140
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
16141 23 hero_newstep_diag.doFloor();
16142 else --hero_newstep_diag;
16143 23 }
16144 else
16145 21 shiftdir = -1;
16146 54 }
16147 7094 else break;
16148
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21 times.
54 }
16149 54 while(shiftdir != -1);
16150 7115 break;
16151 }
16152 1338 else break;
16153
2/2
✓ Branch 0 taken 1705 times.
✓ Branch 1 taken 1462 times.
3167 }
16154 3167 while(shiftdir != -1);
16155 9915 }
16156 }
16157
16158 99382 moveOld2(right);
16159 99382 shiftdir=s;
16160
16161
2/2
✓ Branch 0 taken 89699 times.
✓ Branch 1 taken 9683 times.
99382 if(!walkable)
16162 {
16163
2/2
✓ Branch 0 taken 2869 times.
✓ Branch 1 taken 6814 times.
9683 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16164 {
16165 6814 x = x.getInt();
16166 6814 y = y.getInt();
16167 6814 int32_t v1=bigHitbox?0:8;
16168 6814 int32_t v2=bigHitbox?8:12;
16169
16170
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6814 times.
✓ Branch 4 taken 5924 times.
✓ Branch 5 taken 890 times.
✓ Branch 6 taken 223 times.
✓ Branch 7 taken 6591 times.
7704 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16171
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 890 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 890 times.
✓ Branch 4 taken 645 times.
✓ Branch 5 taken 245 times.
890 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16172
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 245 times.
245 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16173 {
16174
7/12
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 216 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 216 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 216 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 216 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 223 times.
223 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16175 223 sprite::move((zfix)0,(zfix)-1);
16176 223 }
16177
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6591 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6591 times.
✓ Branch 4 taken 667 times.
✓ Branch 5 taken 5924 times.
✓ Branch 6 taken 191 times.
✓ Branch 7 taken 6400 times.
12515 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16178
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5924 times.
✓ Branch 4 taken 5733 times.
✓ Branch 5 taken 191 times.
5924 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16179
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 191 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 191 times.
191 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16180 {
16181
9/12
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 187 times.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 191 times.
191 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16182 191 sprite::move((zfix)0,(zfix)1);
16183 191 }
16184 else
16185 {
16186 6400 pushing=push+1;
16187 6400 z3step=2;
16188 }
16189 6814 }
16190 else
16191 {
16192 2869 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16193
16194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2869 times.
2869 if(action!=swimming)
16195 {
16196 2869 }
16197 }
16198 9683 }
16199
16200 99382 return;
16201 }
16202 }
16203 188324 }
16204 else
16205 {
16206
6/6
✓ Branch 0 taken 595859 times.
✓ Branch 1 taken 2414273 times.
✓ Branch 2 taken 582262 times.
✓ Branch 3 taken 13597 times.
✓ Branch 4 taken 127050 times.
✓ Branch 5 taken 455212 times.
3010132 if(DrunkUp()&&(holddir==-1||holddir==up))
16207 {
16208
5/8
✓ Branch 0 taken 3903 times.
✓ Branch 1 taken 464906 times.
✓ Branch 2 taken 3899 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3903 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
468809 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
16209 {
16210 }
16211 else
16212 {
16213
3/4
✓ Branch 0 taken 432581 times.
✓ Branch 1 taken 36228 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432581 times.
468809 if(charging==0 && spins==0)
16214 {
16215 432581 dir=up;
16216 432581 }
16217
16218 468809 holddir=up;
16219
16220
4/4
✓ Branch 0 taken 63445 times.
✓ Branch 1 taken 341964 times.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 63335 times.
468809 if(DrunkRight()&&shiftdir!=left)
16221 {
16222 63335 shiftdir=right;
16223 63335 }
16224
4/4
✓ Branch 0 taken 52553 times.
✓ Branch 1 taken 289521 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 52473 times.
342074 else if(DrunkLeft()&&shiftdir!=right)
16225 {
16226 52473 shiftdir=left;
16227 52473 }
16228 else
16229 {
16230 289601 shiftdir=-1;
16231 }
16232
16233 //walkable if Ladder can be placed or is already placed vertically
16234
10/18
✓ Branch 0 taken 16485 times.
✓ Branch 1 taken 388924 times.
✓ Branch 2 taken 16485 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 16485 times.
✓ Branch 6 taken 16485 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 16354 times.
✓ Branch 11 taken 16354 times.
✓ Branch 12 taken 16354 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16354 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 16354 times.
405409 if(isSideViewHero() && !toogam && !(((replay_version_check(0, 23) || get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW)) && can_deploy_ladder()) || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16235 {
16236 16354 walkable=false;
16237 16354 }
16238 else
16239 {
16240
7/8
✓ Branch 0 taken 57465 times.
✓ Branch 1 taken 364298 times.
✓ Branch 2 taken 787 times.
✓ Branch 3 taken 56678 times.
✓ Branch 4 taken 963 times.
✓ Branch 5 taken 420013 times.
✓ Branch 6 taken 963 times.
✗ Branch 7 not taken.
421763 if ((can_deploy_ladder() && get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW)) || (ladderx && laddery && ladderdir==up)) justmoved = 2;
16241 421763 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
16242
16243
2/2
✓ Branch 0 taken 229232 times.
✓ Branch 1 taken 192531 times.
421763 if(x.getInt() & 7)
16244 229232 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
16245 else
16246 192531 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
16247
16248 421763 execute(info);
16249
16250
2/2
✓ Branch 0 taken 66639 times.
✓ Branch 1 taken 355124 times.
421763 if(info.isUnwalkable())
16251 {
16252
2/2
✓ Branch 0 taken 65305 times.
✓ Branch 1 taken 1334 times.
66639 if(z3step==2)
16253 {
16254 65305 z3step=1;
16255 65305 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
16256
16257
2/2
✓ Branch 0 taken 37381 times.
✓ Branch 1 taken 27924 times.
65305 if(x.getInt()&7)
16258 37381 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
16259 else
16260 27924 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
16261
16262 65305 execute(info);
16263
16264
2/2
✓ Branch 0 taken 60215 times.
✓ Branch 1 taken 5090 times.
65305 if(info.isUnwalkable())
16265 {
16266 60215 walkable = false;
16267 60215 }
16268 else
16269 {
16270 5090 walkable=true;
16271 }
16272 65305 }
16273 else
16274 {
16275 1334 walkable=false;
16276 }
16277 66639 }
16278 else
16279 {
16280 355124 walkable = true;
16281 }
16282 }
16283
16284 438117 int32_t s=shiftdir;
16285
16286
5/6
✓ Branch 0 taken 3903 times.
✓ Branch 1 taken 434214 times.
✓ Branch 2 taken 3784 times.
✓ Branch 3 taken 119 times.
✓ Branch 4 taken 3903 times.
✗ Branch 5 not taken.
438117 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM))
16287 {
16288 shiftdir=-1;
16289 }
16290 else
16291 {
16292
2/2
✓ Branch 0 taken 52473 times.
✓ Branch 1 taken 385644 times.
438117 if(s==left)
16293 {
16294 52473 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
16295 52473 execute(info);
16296
16297
2/2
✓ Branch 0 taken 7219 times.
✓ Branch 1 taken 45254 times.
52473 if(info.isUnwalkable())
16298 {
16299 7219 shiftdir=-1;
16300 7219 }
16301
2/2
✓ Branch 0 taken 9314 times.
✓ Branch 1 taken 35940 times.
45254 else if(walkable)
16302 {
16303 35940 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
16304 35940 execute(info);
16305
2/2
✓ Branch 0 taken 35859 times.
✓ Branch 1 taken 81 times.
35940 if(info.isUnwalkable())
16306 {
16307 81 shiftdir=-1;
16308 81 }
16309 35940 }
16310 52473 }
16311
2/2
✓ Branch 0 taken 322309 times.
✓ Branch 1 taken 63335 times.
385644 else if(s==right)
16312 {
16313 63335 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
16314 63335 execute(info);
16315
16316
2/2
✓ Branch 0 taken 9185 times.
✓ Branch 1 taken 54150 times.
63335 if(info.isUnwalkable())
16317 {
16318 9185 shiftdir=-1;
16319 9185 }
16320
2/2
✓ Branch 0 taken 10675 times.
✓ Branch 1 taken 43475 times.
54150 else if(walkable)
16321 {
16322 43475 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
16323 43475 execute(info);
16324
16325
2/2
✓ Branch 0 taken 43389 times.
✓ Branch 1 taken 86 times.
43475 if(info.isUnwalkable())
16326 {
16327 86 shiftdir=-1;
16328 86 }
16329 43475 }
16330 63335 }
16331 }
16332
16333 438117 moveOld2(up);
16334 438117 shiftdir=s;
16335
16336
2/2
✓ Branch 0 taken 360214 times.
✓ Branch 1 taken 77903 times.
438117 if(!walkable)
16337 {
16338
2/2
✓ Branch 0 taken 24240 times.
✓ Branch 1 taken 53663 times.
77903 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16339 {
16340
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 53663 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53663 times.
✓ Branch 4 taken 29151 times.
✓ Branch 5 taken 24512 times.
✓ Branch 6 taken 2458 times.
✓ Branch 7 taken 51205 times.
78175 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16341
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24512 times.
✓ Branch 4 taken 5816 times.
✓ Branch 5 taken 18696 times.
24512 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16342
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18696 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18696 times.
18696 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16343 {
16344
9/12
✓ Branch 0 taken 2389 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 2389 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2389 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2361 times.
✓ Branch 7 taken 28 times.
✓ Branch 8 taken 2361 times.
✓ Branch 9 taken 28 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2458 times.
2458 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
16345 2458 sprite::move((zfix)-1,(zfix)0);
16346 2458 }
16347 else
16348 {
16349
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 51205 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51205 times.
✓ Branch 4 taken 22054 times.
✓ Branch 5 taken 29151 times.
✓ Branch 6 taken 2449 times.
✓ Branch 7 taken 48756 times.
80356 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16350
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29151 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29151 times.
✓ Branch 4 taken 26702 times.
✓ Branch 5 taken 2449 times.
29151 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16351
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2449 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2449 times.
2449 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16352 {
16353
10/12
✓ Branch 0 taken 2360 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 2360 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2360 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2347 times.
✓ Branch 7 taken 13 times.
✓ Branch 8 taken 2347 times.
✓ Branch 9 taken 13 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 2447 times.
2449 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
16354 2447 sprite::move((zfix)1,(zfix)0);
16355 2449 }
16356 else
16357 {
16358 48756 pushing=push+1;
16359 }
16360 }
16361
16362 53663 z3step=2;
16363 53663 }
16364 else
16365 {
16366 24240 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16367 24240 z3step=2;
16368 }
16369 77903 }
16370
16371 438117 return;
16372 }
16373 }
16374
16375
6/6
✓ Branch 0 taken 498873 times.
✓ Branch 1 taken 2042450 times.
✓ Branch 2 taken 487030 times.
✓ Branch 3 taken 11843 times.
✓ Branch 4 taken 360009 times.
✓ Branch 5 taken 127021 times.
2541323 if(DrunkDown()&&(holddir==-1||holddir==down))
16376 {
16377
4/8
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 369177 times.
✓ Branch 2 taken 2675 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2675 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
371852 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
16378 {
16379 }
16380 else
16381 {
16382
3/4
✓ Branch 0 taken 366836 times.
✓ Branch 1 taken 5016 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 366836 times.
371852 if(charging==0 && spins==0)
16383 {
16384 366836 dir=down;
16385 366836 }
16386
16387 371852 holddir=down;
16388
16389
4/4
✓ Branch 0 taken 62322 times.
✓ Branch 1 taken 309530 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 62024 times.
371852 if(DrunkRight()&&shiftdir!=left)
16390 {
16391 62024 shiftdir=right;
16392 62024 }
16393
4/4
✓ Branch 0 taken 57733 times.
✓ Branch 1 taken 252095 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 57649 times.
309828 else if(DrunkLeft()&&shiftdir!=right)
16394 {
16395 57649 shiftdir=left;
16396 57649 }
16397 else
16398 {
16399 252179 shiftdir=-1;
16400 }
16401
16402 //bool walkable;
16403
7/12
✓ Branch 0 taken 9145 times.
✓ Branch 1 taken 362707 times.
✓ Branch 2 taken 9145 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9145 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9145 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9145 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 9145 times.
371852 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16404 {
16405 9145 walkable=false;
16406 9145 }
16407 else
16408 {
16409 362707 info = walkflag(x,y+15+z3step,2,down);
16410
16411
2/2
✓ Branch 0 taken 200419 times.
✓ Branch 1 taken 162288 times.
362707 if(x.getInt()&7)
16412 200419 info = info || walkflag(x+16,y+15+z3step,1,down);
16413 else
16414 162288 info = info || walkflagMBlock(x+16, y+15+z3step);
16415
16416 362707 execute(info);
16417
16418
2/2
✓ Branch 0 taken 64615 times.
✓ Branch 1 taken 298092 times.
362707 if(info.isUnwalkable())
16419 {
16420
2/2
✓ Branch 0 taken 63450 times.
✓ Branch 1 taken 1165 times.
64615 if(z3step==2)
16421 {
16422 63450 z3step=1;
16423 63450 info = walkflag(x,y+15+z3step,2,down);
16424
16425
2/2
✓ Branch 0 taken 38586 times.
✓ Branch 1 taken 24864 times.
63450 if(x.getInt()&7)
16426 38586 info = info || walkflag(x+16,y+15+z3step,1,down);
16427 else
16428 24864 info = info || walkflagMBlock(x+16, y+15+z3step);
16429
16430 63450 execute(info);
16431
16432
2/2
✓ Branch 0 taken 58960 times.
✓ Branch 1 taken 4490 times.
63450 if(info.isUnwalkable())
16433 {
16434 58960 walkable = false;
16435 58960 }
16436 else
16437 {
16438 4490 walkable=true;
16439 }
16440 63450 }
16441 else
16442 {
16443 1165 walkable=false;
16444 }
16445 64615 }
16446 else
16447 {
16448 298092 walkable = true;
16449 }
16450 }
16451
16452 371852 int32_t s=shiftdir;
16453
16454
5/6
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 369177 times.
✓ Branch 2 taken 2670 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 2675 times.
✗ Branch 5 not taken.
371852 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM))
16455 {
16456 shiftdir=-1;
16457 }
16458 else
16459 {
16460
2/2
✓ Branch 0 taken 57649 times.
✓ Branch 1 taken 314203 times.
371852 if(s==left)
16461 {
16462 57649 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
16463 57649 execute(info);
16464
16465
2/2
✓ Branch 0 taken 6885 times.
✓ Branch 1 taken 50764 times.
57649 if(info.isUnwalkable())
16466 {
16467 6885 shiftdir=-1;
16468 6885 }
16469
2/2
✓ Branch 0 taken 12250 times.
✓ Branch 1 taken 38514 times.
50764 else if(walkable)
16470 {
16471 38514 info = walkflag(x-1,y+16,1,left);
16472 38514 execute(info);
16473
16474
2/2
✓ Branch 0 taken 38434 times.
✓ Branch 1 taken 80 times.
38514 if(info.isUnwalkable())
16475 {
16476 80 shiftdir=-1;
16477 80 }
16478 38514 }
16479 57649 }
16480
2/2
✓ Branch 0 taken 252179 times.
✓ Branch 1 taken 62024 times.
314203 else if(s==right)
16481 {
16482 62024 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
16483 62024 execute(info);
16484
16485
2/2
✓ Branch 0 taken 9997 times.
✓ Branch 1 taken 52027 times.
62024 if(info.isUnwalkable())
16486 {
16487 9997 shiftdir=-1;
16488 9997 }
16489
2/2
✓ Branch 0 taken 12269 times.
✓ Branch 1 taken 39758 times.
52027 else if(walkable)
16490 {
16491 39758 info = walkflag(x+16,y+16,1,right);
16492 39758 execute(info);
16493
16494
2/2
✓ Branch 0 taken 39672 times.
✓ Branch 1 taken 86 times.
39758 if(info.isUnwalkable())
16495 {
16496 86 shiftdir=-1;
16497 86 }
16498 39758 }
16499 62024 }
16500 }
16501
16502 371852 moveOld2(down);
16503 371852 shiftdir=s;
16504
16505
2/2
✓ Branch 0 taken 302582 times.
✓ Branch 1 taken 69270 times.
371852 if(!walkable)
16506 {
16507
2/2
✓ Branch 0 taken 30553 times.
✓ Branch 1 taken 38717 times.
69270 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16508 {
16509
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 38717 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38717 times.
✓ Branch 4 taken 23711 times.
✓ Branch 5 taken 15006 times.
✓ Branch 6 taken 1953 times.
✓ Branch 7 taken 36764 times.
53723 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16510
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15006 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15006 times.
✓ Branch 4 taken 5754 times.
✓ Branch 5 taken 9252 times.
15006 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16511
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9252 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9252 times.
9252 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16512 {
16513
9/12
✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 1840 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1840 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1832 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 1832 times.
✓ Branch 9 taken 8 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1953 times.
1953 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
16514 1953 sprite::move((zfix)-1,(zfix)0);
16515 1953 }
16516
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 36764 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36764 times.
✓ Branch 4 taken 13053 times.
✓ Branch 5 taken 23711 times.
✓ Branch 6 taken 1790 times.
✓ Branch 7 taken 34974 times.
60475 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16517
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 23711 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23711 times.
✓ Branch 4 taken 21899 times.
✓ Branch 5 taken 1812 times.
23711 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16518
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1812 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1812 times.
1812 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16519 {
16520
9/12
✓ Branch 0 taken 1711 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 1711 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1711 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1705 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 1705 times.
✓ Branch 9 taken 6 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1790 times.
1790 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
16521 1790 sprite::move((zfix)1,(zfix)0);
16522 1790 }
16523 else //if(shiftdir==-1)
16524 {
16525 34974 pushing=push+1;
16526
16527
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 34889 times.
34974 if(action!=swimming)
16528 {
16529 34889 }
16530 }
16531
16532 38717 z3step=2;
16533 38717 }
16534 else
16535 {
16536 30553 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16537
16538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30553 times.
30553 if(action!=swimming)
16539 {
16540 30553 }
16541
16542 30553 z3step=2;
16543 }
16544 69270 }
16545
16546 371852 return;
16547 }
16548 }
16549
16550
6/6
✓ Branch 0 taken 582951 times.
✓ Branch 1 taken 1586520 times.
✓ Branch 2 taken 566510 times.
✓ Branch 3 taken 16441 times.
✓ Branch 4 taken 564905 times.
✓ Branch 5 taken 1605 times.
2169471 if(DrunkLeft()&&(holddir==-1||holddir==left))
16551 {
16552
5/8
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 576684 times.
✓ Branch 2 taken 4511 times.
✓ Branch 3 taken 151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4662 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
581346 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
16553 {
16554 }
16555 else
16556 {
16557
3/4
✓ Branch 0 taken 574800 times.
✓ Branch 1 taken 6546 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 574800 times.
581346 if(charging==0 && spins==0)
16558 {
16559 574800 dir=left;
16560 574800 }
16561
16562 581346 holddir=left;
16563
16564
4/4
✓ Branch 0 taken 75416 times.
✓ Branch 1 taken 505930 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 75413 times.
581346 if(DrunkUp()&&shiftdir!=down)
16565 {
16566 75413 shiftdir=up;
16567 75413 }
16568
4/4
✓ Branch 0 taken 60696 times.
✓ Branch 1 taken 445237 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 60684 times.
505933 else if(DrunkDown()&&shiftdir!=up)
16569 {
16570 60684 shiftdir=down;
16571 60684 }
16572 else
16573 {
16574 445249 shiftdir=-1;
16575 }
16576
16577 //bool walkable;
16578 581346 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
16579
16580
2/2
✓ Branch 0 taken 336579 times.
✓ Branch 1 taken 244767 times.
581346 if(y.getInt()&7)
16581 336579 info = info || walkflag(x-z3step,y+16,1,left);
16582
16583 581346 execute(info);
16584
16585
2/2
✓ Branch 0 taken 71956 times.
✓ Branch 1 taken 509390 times.
581346 if(info.isUnwalkable())
16586 {
16587
2/2
✓ Branch 0 taken 70590 times.
✓ Branch 1 taken 1366 times.
71956 if(z3step==2)
16588 {
16589 70590 z3step=1;
16590 70590 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
16591
16592
2/2
✓ Branch 0 taken 26948 times.
✓ Branch 1 taken 43642 times.
70590 if(y.getInt()&7)
16593 43642 info = info || walkflag(x-z3step,y+16,1,left);
16594
16595 70590 execute(info);
16596
16597
2/2
✓ Branch 0 taken 65773 times.
✓ Branch 1 taken 4817 times.
70590 if(info.isUnwalkable())
16598 {
16599 65773 walkable = false;
16600 65773 }
16601 else
16602 {
16603 4817 walkable=true;
16604 }
16605 70590 }
16606 else
16607 {
16608 1366 walkable=false;
16609 }
16610 71956 }
16611 else
16612 {
16613 509390 walkable = true;
16614 }
16615
16616 581346 int32_t s=shiftdir;
16617
16618
10/14
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 576684 times.
✓ Branch 2 taken 4595 times.
✓ Branch 3 taken 67 times.
✓ Branch 4 taken 4662 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 56334 times.
✓ Branch 7 taken 525012 times.
✓ Branch 8 taken 56334 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 56334 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 56334 times.
✗ Branch 13 not taken.
581346 if((isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
16619 {
16620 56334 shiftdir=-1;
16621 56334 }
16622 else
16623 {
16624
2/2
✓ Branch 0 taken 450890 times.
✓ Branch 1 taken 74122 times.
525012 if(s==up)
16625 {
16626 74122 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
16627 74122 execute(info);
16628
16629
2/2
✓ Branch 0 taken 8595 times.
✓ Branch 1 taken 65527 times.
74122 if(info.isUnwalkable())
16630 {
16631 8595 shiftdir=-1;
16632 8595 }
16633
2/2
✓ Branch 0 taken 9949 times.
✓ Branch 1 taken 55578 times.
65527 else if(walkable)
16634 {
16635 55578 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
16636 55578 execute(info);
16637
16638
2/2
✓ Branch 0 taken 55497 times.
✓ Branch 1 taken 81 times.
55578 if(info.isUnwalkable())
16639 {
16640 81 shiftdir=-1;
16641 81 }
16642 55578 }
16643 74122 }
16644
2/2
✓ Branch 0 taken 390767 times.
✓ Branch 1 taken 60123 times.
450890 else if(s==down)
16645 {
16646 60123 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
16647 60123 execute(info);
16648
16649
2/2
✓ Branch 0 taken 9541 times.
✓ Branch 1 taken 50582 times.
60123 if(info.isUnwalkable())
16650 {
16651 9541 shiftdir=-1;
16652 9541 }
16653
2/2
✓ Branch 0 taken 7937 times.
✓ Branch 1 taken 42645 times.
50582 else if(walkable)
16654 {
16655 42645 info = walkflag(x-1,y+16,1,down);
16656 42645 execute(info);
16657
16658
2/2
✓ Branch 0 taken 42574 times.
✓ Branch 1 taken 71 times.
42645 if(info.isUnwalkable())
16659 {
16660 71 shiftdir=-1;
16661 71 }
16662 42645 }
16663 60123 }
16664 }
16665
16666 581346 moveOld2(left);
16667 581346 shiftdir=s;
16668
16669
2/2
✓ Branch 0 taken 514207 times.
✓ Branch 1 taken 67139 times.
581346 if(!walkable)
16670 {
16671
2/2
✓ Branch 0 taken 22438 times.
✓ Branch 1 taken 44701 times.
67139 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16672 {
16673 44701 int32_t v1=bigHitbox?0:8;
16674 44701 int32_t v2=bigHitbox?8:12;
16675
16676
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 44701 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44701 times.
✓ Branch 4 taken 36868 times.
✓ Branch 5 taken 7833 times.
✓ Branch 6 taken 1401 times.
✓ Branch 7 taken 43300 times.
52534 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16677
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7833 times.
✓ Branch 4 taken 3903 times.
✓ Branch 5 taken 3930 times.
7833 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16678
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3930 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3930 times.
3930 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16679 {
16680
9/12
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 1302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1302 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1298 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 1298 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1401 times.
1401 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16681 1401 sprite::move((zfix)0,(zfix)-1);
16682 1401 }
16683
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 43300 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 43300 times.
✓ Branch 4 taken 6432 times.
✓ Branch 5 taken 36868 times.
✓ Branch 6 taken 760 times.
✓ Branch 7 taken 42540 times.
80168 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
16684
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36868 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36868 times.
✓ Branch 4 taken 36108 times.
✓ Branch 5 taken 760 times.
36868 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16685
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16686 {
16687
8/12
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 708 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 708 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 708 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 708 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 759 times.
760 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16688 759 sprite::move((zfix)0,(zfix)1);
16689 760 }
16690 else //if(shiftdir==-1)
16691 {
16692 42540 pushing=push+1;
16693
16694
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 42335 times.
42540 if(action!=swimming)
16695 {
16696 42335 }
16697 }
16698
16699 44701 z3step=2;
16700 44701 }
16701 else
16702 {
16703 22438 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16704
16705
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 22395 times.
22438 if(action!=swimming)
16706 {
16707 22395 }
16708
16709 22438 z3step=2;
16710 }
16711 67139 }
16712
16713 581346 return;
16714 }
16715 }
16716
16717
5/6
✓ Branch 0 taken 639286 times.
✓ Branch 1 taken 948839 times.
✓ Branch 2 taken 622255 times.
✓ Branch 3 taken 17031 times.
✓ Branch 4 taken 622255 times.
✗ Branch 5 not taken.
1588125 if(DrunkRight()&&(holddir==-1||holddir==right))
16718 {
16719
5/8
✓ Branch 0 taken 4663 times.
✓ Branch 1 taken 634623 times.
✓ Branch 2 taken 4484 times.
✓ Branch 3 taken 179 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4663 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
639286 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
16720 {
16721 }
16722 else
16723 {
16724
3/4
✓ Branch 0 taken 631155 times.
✓ Branch 1 taken 8131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 631155 times.
639286 if(charging==0 && spins==0)
16725 {
16726 631155 dir=right;
16727 631155 }
16728
16729 639286 holddir=right;
16730
16731
4/4
✓ Branch 0 taken 81981 times.
✓ Branch 1 taken 557305 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 81950 times.
639286 if(DrunkUp()&&shiftdir!=down)
16732 {
16733 81950 shiftdir=up;
16734 81950 }
16735
4/4
✓ Branch 0 taken 66244 times.
✓ Branch 1 taken 491092 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 66231 times.
557336 else if(DrunkDown()&&shiftdir!=up)
16736 {
16737 66231 shiftdir=down;
16738 66231 }
16739 else
16740 {
16741 491105 shiftdir=-1;
16742 }
16743
16744 //bool walkable;
16745 639286 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
16746
16747
2/2
✓ Branch 0 taken 276144 times.
✓ Branch 1 taken 363142 times.
639286 if(y.getInt()&7)
16748 363142 info = info || walkflag(x+15+z3step,y+16,1,right);
16749
16750 639286 execute(info);
16751
16752
2/2
✓ Branch 0 taken 88289 times.
✓ Branch 1 taken 550997 times.
639286 if(info.isUnwalkable())
16753 {
16754
2/2
✓ Branch 0 taken 86869 times.
✓ Branch 1 taken 1420 times.
88289 if(z3step==2)
16755 {
16756 86869 z3step=1;
16757 86869 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
16758
16759
2/2
✓ Branch 0 taken 33022 times.
✓ Branch 1 taken 53847 times.
86869 if(y.getInt()&7)
16760 53847 info = info || walkflag(x+15+z3step,y+16,1,right);
16761
16762 86869 execute(info);
16763
16764
2/2
✓ Branch 0 taken 79508 times.
✓ Branch 1 taken 7361 times.
86869 if(info.isUnwalkable())
16765 {
16766 79508 walkable = false;
16767 79508 }
16768 else
16769 {
16770 7361 walkable=true;
16771 }
16772 86869 }
16773 else
16774 {
16775 1420 walkable=false;
16776 }
16777 88289 }
16778 else
16779 {
16780 550997 walkable = true;
16781 }
16782
16783 639286 int32_t s=shiftdir;
16784
16785
10/14
✓ Branch 0 taken 4663 times.
✓ Branch 1 taken 634623 times.
✓ Branch 2 taken 4647 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 4663 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 65926 times.
✓ Branch 7 taken 573360 times.
✓ Branch 8 taken 65926 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 65926 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 65926 times.
✗ Branch 13 not taken.
639286 if((isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
16786 {
16787 65926 shiftdir=-1;
16788 65926 }
16789 else
16790 {
16791
2/2
✓ Branch 0 taken 493172 times.
✓ Branch 1 taken 80188 times.
573360 if(s==up)
16792 {
16793 80188 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
16794 80188 execute(info);
16795
16796
2/2
✓ Branch 0 taken 10529 times.
✓ Branch 1 taken 69659 times.
80188 if(info.isUnwalkable())
16797 {
16798 10529 shiftdir=-1;
16799 10529 }
16800
2/2
✓ Branch 0 taken 11741 times.
✓ Branch 1 taken 57918 times.
69659 else if(walkable)
16801 {
16802 57918 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
16803 57918 execute(info);
16804
16805
2/2
✓ Branch 0 taken 57827 times.
✓ Branch 1 taken 91 times.
57918 if(info.isUnwalkable())
16806 {
16807 91 shiftdir=-1;
16808 91 }
16809 57918 }
16810 80188 }
16811
2/2
✓ Branch 0 taken 427418 times.
✓ Branch 1 taken 65754 times.
493172 else if(s==down)
16812 {
16813 65754 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
16814 65754 execute(info);
16815
16816
2/2
✓ Branch 0 taken 11429 times.
✓ Branch 1 taken 54325 times.
65754 if(info.isUnwalkable())
16817 {
16818 11429 shiftdir=-1;
16819 11429 }
16820
2/2
✓ Branch 0 taken 9297 times.
✓ Branch 1 taken 45028 times.
54325 else if(walkable)
16821 {
16822 45028 info = walkflag(x+16,y+16,1,down);
16823 45028 execute(info);
16824
16825
2/2
✓ Branch 0 taken 44948 times.
✓ Branch 1 taken 80 times.
45028 if(info.isUnwalkable())
16826 {
16827 80 shiftdir=-1;
16828 80 }
16829 45028 }
16830 65754 }
16831 }
16832
16833 639286 moveOld2(right);
16834 639286 shiftdir=s;
16835
16836
2/2
✓ Branch 0 taken 558358 times.
✓ Branch 1 taken 80928 times.
639286 if(!walkable)
16837 {
16838
2/2
✓ Branch 0 taken 27201 times.
✓ Branch 1 taken 53727 times.
80928 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16839 {
16840 53727 int32_t v1=bigHitbox?0:8;
16841 53727 int32_t v2=bigHitbox?8:12;
16842
16843 161181 info = !walkflag(x+16,y+v1,1,right)&&
16844 107454 !walkflag(x+16,y+v2,1,right)&&
16845 53727 walkflag(x+16,y+15,1,right);
16846
16847 //do NOT execute these
16848
2/2
✓ Branch 0 taken 1667 times.
✓ Branch 1 taken 52060 times.
53727 if(info.isUnwalkable())
16849 {
16850
10/12
✓ Branch 0 taken 1570 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 1570 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1570 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1569 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1569 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1666 times.
1667 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16851 1666 sprite::move((zfix)0,(zfix)-1);
16852 1667 }
16853 else
16854 {
16855 156180 info = walkflag(x+16,y+v1, 1,right)&&
16856 104120 !walkflag(x+16,y+v2-1,1,right)&&
16857 52060 !walkflag(x+16,y+15, 1,right);
16858
16859
2/2
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 51188 times.
52060 if(info.isUnwalkable())
16860 {
16861
7/12
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 832 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 832 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 872 times.
872 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16862 872 sprite::move((zfix)0,(zfix)1);
16863 872 }
16864 else //if(shiftdir==-1)
16865 {
16866 51188 pushing=push+1;
16867 51188 z3step=2;
16868
16869
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 51122 times.
51188 if(action!=swimming)
16870 {
16871 51122 }
16872 }
16873 }
16874
16875 53727 z3step=2;
16876 53727 }
16877 else
16878 {
16879 27201 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16880
16881
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 27191 times.
27201 if(action!=swimming)
16882 {
16883 27191 }
16884
16885 27201 z3step=2;
16886 }
16887 80928 }
16888
16889 639286 return;
16890 }
16891 }
16892 }
16893
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1137163 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1137163 if(shield_forcedir > -1 && action != rafting)
16894 dir = shield_forcedir;
16895 1137163 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
16896 1137163 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
16897 1137163 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
16898 1137163 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
16899 1137163 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
16900
16901
8/12
✓ Branch 0 taken 151196 times.
✓ Branch 1 taken 985967 times.
✓ Branch 2 taken 151196 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 151196 times.
✓ Branch 6 taken 151196 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 148387 times.
✓ Branch 9 taken 2809 times.
✓ Branch 10 taken 148387 times.
✗ Branch 11 not taken.
1137163 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
16902 {
16903
8/12
✓ Branch 0 taken 571 times.
✓ Branch 1 taken 147816 times.
✓ Branch 2 taken 526 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 479 times.
✓ Branch 5 taken 47 times.
✓ Branch 6 taken 479 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 479 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
148387 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
16904 {
16905 //action=swimming;
16906
3/12
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 360 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
479 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
16907 {
16908 hopclk = 0xFF;
16909 }
16910 479 }
16911 148387 }
16912
16913 1137163 return;
16914 } //endif (LTTPWALK)
16915 3778232 temp_step = hero_newstep;
16916 3778232 temp_x = x;
16917 3778232 temp_y = y;
16918
16919
7/8
✓ Branch 0 taken 2471837 times.
✓ Branch 1 taken 1306395 times.
✓ Branch 2 taken 2420307 times.
✓ Branch 3 taken 51530 times.
✓ Branch 4 taken 59406 times.
✓ Branch 5 taken 2412431 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 59406 times.
3778232 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
16920 {
16921
2/4
✓ Branch 0 taken 59406 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 59406 times.
59406 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16922 goto LEFTRIGHT_NEWMOVE;
16923 59406 else goto LEFTRIGHT_OLDMOVE;
16924 }
16925
16926 // make it easier to get in left & right doors
16927
16928 //ignore ladder for this part. sigh sigh sigh -DD
16929 3718826 oldladderx = ladderx;
16930 3718826 oldladdery = laddery;
16931
2/4
✓ Branch 0 taken 3718826 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3718826 times.
3718826 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16932 {
16933 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
16934 {
16935 do
16936 {
16937 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
16938 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
16939
16940 if(info.isUnwalkable())
16941 {
16942 if(temp_x != int32_t(temp_x))
16943 {
16944 temp_x = floor((double)temp_x);
16945 }
16946 else if(temp_step > 1)
16947 {
16948 if(temp_step != int32_t(temp_step)) //floor
16949 temp_step = floor((double)temp_step);
16950 else --temp_step;
16951 }
16952 else
16953 break;
16954 }
16955 }
16956 while(info.isUnwalkable());
16957
16958 if(!info.isUnwalkable())
16959 {
16960 x = temp_x;
16961 y = temp_y;
16962 hero_newstep = temp_step;
16963 //ONLY process the side-effects of the above walkflag if Hero will actually move
16964 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16965 execute(info);
16966 moveOld2(left);
16967 return;
16968 }
16969 temp_x = x;
16970 temp_y = y;
16971 temp_step = hero_newstep;
16972 }
16973
16974 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
16975 {
16976 do
16977 {
16978 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16979 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
16980
16981 if(info.isUnwalkable())
16982 {
16983 if(temp_x != int32_t(temp_x))
16984 {
16985 temp_x = floor((double)temp_x);
16986 }
16987 else if(temp_step > 1)
16988 {
16989 if(temp_step != int32_t(temp_step)) //floor
16990 temp_step = floor((double)temp_step);
16991 else --temp_step;
16992 }
16993 else
16994 break;
16995 }
16996 }
16997 while(info.isUnwalkable());
16998
16999 if(!info.isUnwalkable())
17000 {
17001 x = temp_x;
17002 y = temp_y;
17003 hero_newstep = temp_step;
17004 execute(info);
17005 moveOld2(right);
17006 return;
17007 }
17008 temp_x = x;
17009 temp_y = y;
17010 temp_step = hero_newstep;
17011 }
17012
17013 ladderx = oldladderx;
17014 laddery = oldladdery;
17015
17016 if(DrunkUp())
17017 {
17018 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17019 {
17020 if(dir!=up && dir!=down)
17021 {
17022 if(xoff>2&&xoff<6)
17023 {
17024 moveOld2(dir);
17025 }
17026 else if(xoff>=6)
17027 {
17028 moveOld2(right);
17029 }
17030 else if(xoff>=1)
17031 {
17032 moveOld2(left);
17033 }
17034 }
17035 else
17036 {
17037 if(xoff>=4)
17038 {
17039 moveOld2(right);
17040 }
17041 else if(xoff<4)
17042 {
17043 moveOld2(left);
17044 }
17045 }
17046 }
17047 else
17048 {
17049 do
17050 {
17051 if(action==swimming || IsSideSwim() || action == swimhit)
17052 {
17053 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
17054
17055 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,SWITCHBLOCK_STATE) &&
17056 !(iswaterex(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
17057 iswaterex(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
17058 info.setUnwalkable(true);
17059 }
17060 else
17061 {
17062 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
17063 if(x.getInt() & 7)
17064 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
17065 else
17066 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
17067 }
17068
17069 if(info.isUnwalkable())
17070 {
17071 if(temp_y != int32_t(temp_y))
17072 {
17073 temp_y = floor((double)temp_y);
17074 }
17075 else if(temp_step > 1)
17076 {
17077 if(temp_step != int32_t(temp_step)) //floor
17078 temp_step = floor((double)temp_step);
17079 else --temp_step;
17080 }
17081 else
17082 break;
17083 }
17084 }
17085 while(info.isUnwalkable());
17086
17087 execute(info);
17088
17089 if(!info.isUnwalkable())
17090 {
17091 x = temp_x;
17092 y = temp_y;
17093 hero_newstep = temp_step;
17094 moveOld2(up);
17095 return;
17096 }
17097
17098 if(!DrunkLeft() && !DrunkRight())
17099 {
17100 if(NO_GRIDLOCK)
17101 {
17102 x = x.getInt();
17103 y = y.getInt();
17104 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17105 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17106 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17107 {
17108 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
17109 sprite::move((zfix)-1,(zfix)0);
17110 }
17111 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17112 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17113 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17114 {
17115 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
17116 sprite::move((zfix)1,(zfix)0);
17117 }
17118 else
17119 {
17120 pushing=push+1;
17121 }
17122 }
17123 else pushing=push+1;
17124
17125 if(charging==0 && spins==0)
17126 {
17127 dir=up;
17128 }
17129
17130 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17131 {
17132 herostep();
17133 }
17134
17135 return;
17136 }
17137 else
17138 {
17139 goto LEFTRIGHT_NEWMOVE;
17140 }
17141 }
17142
17143 return;
17144 }
17145
17146 if(DrunkDown())
17147 {
17148 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17149 {
17150 if(dir!=up && dir!=down)
17151 {
17152 if(xoff>2&&xoff<6)
17153 {
17154 moveOld2(dir);
17155 }
17156 else if(xoff>=6)
17157 {
17158 moveOld2(right);
17159 }
17160 else if(xoff>=1)
17161 {
17162 moveOld2(left);
17163 }
17164 }
17165 else
17166 {
17167 if(xoff>=4)
17168 {
17169 moveOld2(right);
17170 }
17171 else if(xoff<4)
17172 {
17173 moveOld2(left);
17174 }
17175 }
17176 }
17177 else
17178 {
17179 do
17180 {
17181 if(action==swimming || IsSideSwim() || action == swimhit)
17182 {
17183 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
17184
17185 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,SWITCHBLOCK_STATE) &&
17186 !(iswaterex(MAPCOMBO(temp_x, temp_y+15+temp_step), currmap, currscr, -1, temp_x, temp_y+15+temp_step, true, false) &&
17187 iswaterex(MAPCOMBO(temp_x+15, temp_y+15+temp_step), currmap, currscr, -1, temp_x+15, temp_y+15+temp_step, true, false)))
17188 info.setUnwalkable(true);
17189 }
17190 else
17191 {
17192 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
17193 if(x.getInt() & 7)
17194 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
17195 else
17196 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
17197 }
17198
17199 if(info.isUnwalkable())
17200 {
17201 if(temp_y != int32_t(temp_y))
17202 {
17203 temp_y = floor((double)temp_y);
17204 }
17205 else if(temp_step > 1)
17206 {
17207 if(temp_step != int32_t(temp_step)) //floor
17208 temp_step = floor((double)temp_step);
17209 else --temp_step;
17210 }
17211 else
17212 break;
17213 }
17214 }
17215 while(info.isUnwalkable());
17216
17217 execute(info);
17218
17219 if(!info.isUnwalkable())
17220 {
17221 x = temp_x;
17222 y = temp_y;
17223 hero_newstep = temp_step;
17224 moveOld2(down);
17225 return;
17226 }
17227
17228 if(!DrunkLeft() && !DrunkRight())
17229 {
17230 if(NO_GRIDLOCK)
17231 {
17232 x = x.getInt();
17233 y = y.getInt();
17234 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
17235 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
17236 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
17237 {
17238 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
17239 sprite::move((zfix)-1,(zfix)0);
17240 }
17241 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
17242 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
17243 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
17244 {
17245 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
17246 sprite::move((zfix)1,(zfix)0);
17247 }
17248 else
17249 {
17250 pushing=push+1;
17251 }
17252 }
17253 else pushing=push+1;
17254
17255 if(charging==0 && spins==0)
17256 {
17257 dir=down;
17258 }
17259
17260 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17261 {
17262 herostep();
17263 }
17264
17265 return;
17266 }
17267 else goto LEFTRIGHT_NEWMOVE;
17268 }
17269
17270 return;
17271 }
17272
17273 LEFTRIGHT_NEWMOVE:
17274 temp_x = x;
17275 temp_y = y;
17276 temp_step = hero_newstep;
17277 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_qr(qr_FREEFORM) && !toogam)
17278 {
17279 return;
17280 }
17281
17282 if(DrunkLeft())
17283 {
17284 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17285 {
17286 if(dir!=left && dir!=right)
17287 {
17288 if(yoff>2&&yoff<6)
17289 {
17290 moveOld2(dir);
17291 }
17292 else if(yoff>=6)
17293 {
17294 moveOld2(down);
17295 }
17296 else if(yoff>=1)
17297 {
17298 moveOld2(up);
17299 }
17300 }
17301 else
17302 {
17303 if(yoff>=4)
17304 {
17305 moveOld2(down);
17306 }
17307 else if(yoff<4)
17308 {
17309 moveOld2(up);
17310 }
17311 }
17312 }
17313 else
17314 {
17315 do
17316 {
17317 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
17318 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
17319
17320 if(y.getInt() & 7)
17321 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
17322
17323 if(info.isUnwalkable())
17324 {
17325 if(temp_x != int32_t(temp_x))
17326 {
17327 temp_x = floor((double)temp_x);
17328 }
17329 else if(temp_step > 1)
17330 {
17331 if(temp_step != int32_t(temp_step)) //floor
17332 temp_step = floor((double)temp_step);
17333 else --temp_step;
17334 }
17335 else
17336 break;
17337 }
17338 }
17339 while(info.isUnwalkable());
17340
17341 execute(info);
17342
17343 if(!info.isUnwalkable())
17344 {
17345 x = temp_x;
17346 y = temp_y;
17347 hero_newstep = temp_step;
17348 moveOld2(left);
17349 return;
17350 }
17351
17352 if(!DrunkUp() && !DrunkDown())
17353 {
17354 if(NO_GRIDLOCK)
17355 {
17356 x = x.getInt();
17357 y = y.getInt();
17358 int32_t v1=bigHitbox?0:8;
17359 int32_t v2=bigHitbox?8:12;
17360
17361 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
17362 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
17363 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
17364 {
17365 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17366 sprite::move((zfix)0,(zfix)-1);
17367 }
17368 else if(_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
17369 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
17370 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
17371 {
17372 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17373 sprite::move((zfix)0,(zfix)1);
17374 }
17375 else
17376 {
17377 pushing=push+1;
17378 }
17379 }
17380 else pushing=push+1;
17381
17382 if(charging==0 && spins==0)
17383 {
17384 dir=left;
17385 }
17386
17387 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17388 {
17389 herostep();
17390 }
17391
17392 return;
17393 }
17394 }
17395
17396 return;
17397 }
17398
17399 if(DrunkRight())
17400 {
17401 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17402 {
17403 if(dir!=left && dir!=right)
17404 {
17405 if(yoff>2&&yoff<6)
17406 {
17407 moveOld2(dir);
17408 }
17409 else if(yoff>=6)
17410 {
17411 moveOld2(down);
17412 }
17413 else if(yoff>=1)
17414 {
17415 moveOld2(up);
17416 }
17417 }
17418 else
17419 {
17420 if(yoff>=4)
17421 {
17422 moveOld2(down);
17423 }
17424 else if(yoff<4)
17425 {
17426 moveOld2(up);
17427 }
17428 }
17429 }
17430 else
17431 {
17432 do
17433 {
17434 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
17435 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
17436
17437 if(y.getInt() & 7)
17438 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
17439
17440 if(info.isUnwalkable())
17441 {
17442 if(temp_x != int32_t(temp_x))
17443 {
17444 temp_x = floor((double)temp_x);
17445 }
17446 else if(temp_step > 1)
17447 {
17448 if(temp_step != int32_t(temp_step)) //floor
17449 temp_step = floor((double)temp_step);
17450 else --temp_step;
17451 }
17452 else
17453 break;
17454 }
17455 }
17456 while(info.isUnwalkable());
17457
17458 execute(info);
17459
17460 if(!info.isUnwalkable())
17461 {
17462 x = temp_x;
17463 y = temp_y;
17464 hero_newstep = temp_step;
17465 moveOld2(right);
17466 return;
17467 }
17468
17469 if(!DrunkUp() && !DrunkDown())
17470 {
17471 if(NO_GRIDLOCK)
17472 {
17473 x = x.getInt();
17474 y = y.getInt();
17475 int32_t v1=bigHitbox?0:8;
17476 int32_t v2=bigHitbox?8:12;
17477
17478 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
17479 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
17480 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
17481 {
17482 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17483 sprite::move((zfix)0,(zfix)-1);
17484 }
17485 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
17486 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
17487 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
17488 {
17489 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17490 sprite::move((zfix)0,(zfix)1);
17491 }
17492 else
17493 {
17494 pushing=push+1;
17495 }
17496 }
17497 else pushing=push+1;
17498
17499 if(charging==0 && spins==0)
17500 {
17501 dir=right;
17502 }
17503
17504 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17505 {
17506 herostep();
17507 }
17508
17509 return;
17510 }
17511 }
17512 }
17513 }
17514 else
17515 {
17516 7437652 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
17517 3718826 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
17518
17519
10/10
✓ Branch 0 taken 2412431 times.
✓ Branch 1 taken 1306395 times.
✓ Branch 2 taken 304273 times.
✓ Branch 3 taken 2108158 times.
✓ Branch 4 taken 186364 times.
✓ Branch 5 taken 117909 times.
✓ Branch 6 taken 1889 times.
✓ Branch 7 taken 184475 times.
✓ Branch 8 taken 358 times.
✓ Branch 9 taken 1531 times.
3718826 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
17520 {
17521 //ONLY process the side-effects of the above walkflag if Hero will actually move
17522 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
17523 1531 execute(info);
17524 1531 moveOld2(left);
17525 1531 return;
17526 }
17527
17528 7434590 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
17529 3717295 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
17530
17531
10/10
✓ Branch 0 taken 2410900 times.
✓ Branch 1 taken 1306395 times.
✓ Branch 2 taken 337877 times.
✓ Branch 3 taken 2073023 times.
✓ Branch 4 taken 201208 times.
✓ Branch 5 taken 136669 times.
✓ Branch 6 taken 2221 times.
✓ Branch 7 taken 198987 times.
✓ Branch 8 taken 406 times.
✓ Branch 9 taken 1815 times.
3717295 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
17532 {
17533 1815 execute(info);
17534 1815 moveOld2(right);
17535 1815 return;
17536 }
17537
17538 3715480 ladderx = oldladderx;
17539 3715480 laddery = oldladdery;
17540
17541
2/2
✓ Branch 0 taken 416041 times.
✓ Branch 1 taken 3299439 times.
3715480 if(DrunkUp())
17542 {
17543
11/14
✓ Branch 0 taken 11759 times.
✓ Branch 1 taken 404282 times.
✓ Branch 2 taken 10988 times.
✓ Branch 3 taken 771 times.
✓ Branch 4 taken 8233 times.
✓ Branch 5 taken 2755 times.
✓ Branch 6 taken 8233 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8233 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8233 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 8230 times.
416041 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17544 {
17545
4/4
✓ Branch 0 taken 8196 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 8195 times.
8230 if(dir!=up && dir!=down)
17546 {
17547
4/4
✓ Branch 0 taken 5693 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 2427 times.
✓ Branch 3 taken 3266 times.
8195 if(xoff>2&&xoff<6)
17548 {
17549 3266 moveOld2(dir);
17550 3266 }
17551
2/2
✓ Branch 0 taken 2427 times.
✓ Branch 1 taken 2502 times.
4929 else if(xoff>=6)
17552 {
17553 2427 moveOld2(right);
17554 2427 }
17555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2502 times.
2502 else if(xoff>=1)
17556 {
17557 2502 moveOld2(left);
17558 2502 }
17559 8195 }
17560 else
17561 {
17562
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 25 times.
35 if(xoff>=4)
17563 {
17564 10 moveOld2(right);
17565 10 }
17566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 else if(xoff<4)
17567 {
17568 25 moveOld2(left);
17569 25 }
17570 }
17571 8230 }
17572 else
17573 {
17574
4/6
✓ Branch 0 taken 381431 times.
✓ Branch 1 taken 26380 times.
✓ Branch 2 taken 381431 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 381431 times.
407811 if(action==swimming || IsSideSwim() || action == swimhit)
17575 {
17576 26380 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
17577
17578
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 26380 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26380 times.
✓ Branch 4 taken 2023 times.
✓ Branch 5 taken 24357 times.
✓ Branch 6 taken 21669 times.
✓ Branch 7 taken 4711 times.
50737 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
17579
2/2
✓ Branch 0 taken 4471 times.
✓ Branch 1 taken 19886 times.
44243 !(iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
17580 19886 iswaterex(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
17581 4711 info.setUnwalkable(true);
17582 26380 }
17583 else
17584 {
17585 381431 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
17586
2/2
✓ Branch 0 taken 777 times.
✓ Branch 1 taken 380654 times.
381431 if(x.getInt() & 7)
17587 777 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
17588 else
17589 380654 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
17590 }
17591
17592 407811 execute(info);
17593
17594
2/2
✓ Branch 0 taken 169867 times.
✓ Branch 1 taken 237944 times.
407811 if(!info.isUnwalkable())
17595 {
17596 237944 moveOld2(up);
17597 237944 return;
17598 }
17599
17600
4/4
✓ Branch 0 taken 151084 times.
✓ Branch 1 taken 18783 times.
✓ Branch 2 taken 18777 times.
✓ Branch 3 taken 132307 times.
169867 if(!DrunkLeft() && !DrunkRight())
17601 {
17602
2/4
✓ Branch 0 taken 132307 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132307 times.
132307 if(NO_GRIDLOCK)
17603 {
17604 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17605 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17606 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17607 {
17608 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
17609 sprite::move((zfix)-1,(zfix)0);
17610 }
17611 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17612 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17613 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17614 {
17615 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
17616 sprite::move((zfix)1,(zfix)0);
17617 }
17618 else
17619 {
17620 pushing=push+1;
17621 }
17622 }
17623 132307 else pushing=push+1;
17624
17625
4/4
✓ Branch 0 taken 132124 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 132028 times.
132307 if(charging==0 && spins==0)
17626 {
17627 132028 dir=up;
17628 132028 }
17629
17630
5/8
✓ Branch 0 taken 129280 times.
✓ Branch 1 taken 3027 times.
✓ Branch 2 taken 129280 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129280 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 129280 times.
132307 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17631 {
17632 129280 herostep();
17633 129280 }
17634
17635 132307 return;
17636 }
17637 else
17638 {
17639 37560 goto LEFTRIGHT_OLDMOVE;
17640 }
17641 }
17642
17643 8230 return;
17644 }
17645
17646
2/2
✓ Branch 0 taken 370268 times.
✓ Branch 1 taken 2929171 times.
3299439 if(DrunkDown())
17647 {
17648
11/14
✓ Branch 0 taken 10692 times.
✓ Branch 1 taken 359576 times.
✓ Branch 2 taken 9973 times.
✓ Branch 3 taken 719 times.
✓ Branch 4 taken 6692 times.
✓ Branch 5 taken 3281 times.
✓ Branch 6 taken 6692 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6692 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6692 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 6691 times.
370268 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17649 {
17650
3/4
✓ Branch 0 taken 6691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 6688 times.
6691 if(dir!=up && dir!=down)
17651 {
17652
4/4
✓ Branch 0 taken 4674 times.
✓ Branch 1 taken 2014 times.
✓ Branch 2 taken 2000 times.
✓ Branch 3 taken 2674 times.
6688 if(xoff>2&&xoff<6)
17653 {
17654 2674 moveOld2(dir);
17655 2674 }
17656
2/2
✓ Branch 0 taken 2000 times.
✓ Branch 1 taken 2014 times.
4014 else if(xoff>=6)
17657 {
17658 2000 moveOld2(right);
17659 2000 }
17660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2014 times.
2014 else if(xoff>=1)
17661 {
17662 2014 moveOld2(left);
17663 2014 }
17664 6688 }
17665 else
17666 {
17667
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(xoff>=4)
17668 {
17669 3 moveOld2(right);
17670 3 }
17671 else if(xoff<4)
17672 {
17673 moveOld2(left);
17674 }
17675 }
17676 6691 }
17677 else
17678 {
17679
4/6
✓ Branch 0 taken 340051 times.
✓ Branch 1 taken 23526 times.
✓ Branch 2 taken 340051 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 340051 times.
363577 if(action==swimming || IsSideSwim() || action == swimhit)
17680 {
17681 23526 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
17682
17683
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 23526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23526 times.
✓ Branch 4 taken 2312 times.
✓ Branch 5 taken 21214 times.
✓ Branch 6 taken 17545 times.
✓ Branch 7 taken 5981 times.
44740 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
17684
2/2
✓ Branch 0 taken 5786 times.
✓ Branch 1 taken 15428 times.
36642 !(iswaterex(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
17685 15428 iswaterex(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
17686 5981 info.setUnwalkable(true);
17687 23526 }
17688 else
17689 {
17690 340051 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
17691
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 339327 times.
340051 if(x.getInt() & 7)
17692 724 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
17693 else
17694 339327 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
17695 }
17696
17697 363577 execute(info);
17698
17699
2/2
✓ Branch 0 taken 167095 times.
✓ Branch 1 taken 196482 times.
363577 if(!info.isUnwalkable())
17700 {
17701 196482 moveOld2(down);
17702 196482 return;
17703 }
17704
17705
4/4
✓ Branch 0 taken 146281 times.
✓ Branch 1 taken 20814 times.
✓ Branch 2 taken 20409 times.
✓ Branch 3 taken 125872 times.
167095 if(!DrunkLeft() && !DrunkRight())
17706 {
17707
2/4
✓ Branch 0 taken 125872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125872 times.
125872 if(NO_GRIDLOCK)
17708 {
17709 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
17710 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
17711 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
17712 {
17713 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
17714 sprite::move((zfix)-1,(zfix)0);
17715 }
17716 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
17717 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
17718 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
17719 {
17720 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
17721 sprite::move((zfix)1,(zfix)0);
17722 }
17723 else
17724 {
17725 pushing=push+1;
17726 }
17727 }
17728 125872 else pushing=push+1;
17729
17730
2/4
✓ Branch 0 taken 125872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125872 times.
125872 if(charging==0 && spins==0)
17731 {
17732 125872 dir=down;
17733 125872 }
17734
17735
5/8
✓ Branch 0 taken 123206 times.
✓ Branch 1 taken 2666 times.
✓ Branch 2 taken 123206 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 123206 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 123206 times.
125872 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17736 {
17737 123206 herostep();
17738 123206 }
17739
17740 125872 return;
17741 }
17742 41223 else goto LEFTRIGHT_OLDMOVE;
17743 }
17744
17745 6691 return;
17746 }
17747
17748 LEFTRIGHT_OLDMOVE:
17749
17750
7/8
✓ Branch 0 taken 2014889 times.
✓ Branch 1 taken 1052471 times.
✓ Branch 2 taken 1959535 times.
✓ Branch 3 taken 55354 times.
✓ Branch 4 taken 55683 times.
✓ Branch 5 taken 1959206 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 55683 times.
3067360 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
17751 {
17752 55683 return;
17753 }
17754
17755
2/2
✓ Branch 0 taken 462606 times.
✓ Branch 1 taken 2549071 times.
3011677 if(DrunkLeft())
17756 {
17757
11/14
✓ Branch 0 taken 8415 times.
✓ Branch 1 taken 454191 times.
✓ Branch 2 taken 7962 times.
✓ Branch 3 taken 453 times.
✓ Branch 4 taken 7343 times.
✓ Branch 5 taken 619 times.
✓ Branch 6 taken 7343 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7343 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7343 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 7341 times.
462606 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17758 {
17759
3/4
✓ Branch 0 taken 7332 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7332 times.
7341 if(dir!=left && dir!=right)
17760 {
17761
4/4
✓ Branch 0 taken 5180 times.
✓ Branch 1 taken 2152 times.
✓ Branch 2 taken 2240 times.
✓ Branch 3 taken 2940 times.
7332 if(yoff>2&&yoff<6)
17762 {
17763 2940 moveOld2(dir);
17764 2940 }
17765
2/2
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 2152 times.
4392 else if(yoff>=6)
17766 {
17767 2240 moveOld2(down);
17768 2240 }
17769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2152 times.
2152 else if(yoff>=1)
17770 {
17771 2152 moveOld2(up);
17772 2152 }
17773 7332 }
17774 else
17775 {
17776
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 if(yoff>=4)
17777 {
17778 6 moveOld2(down);
17779 6 }
17780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(yoff<4)
17781 {
17782 3 moveOld2(up);
17783 3 }
17784 }
17785 7341 }
17786 else
17787 {
17788 910530 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
17789 455265 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
17790
17791 455265 execute(info);
17792
17793
2/2
✓ Branch 0 taken 164044 times.
✓ Branch 1 taken 291221 times.
455265 if(!info.isUnwalkable())
17794 {
17795 291221 moveOld2(left);
17796 291221 return;
17797 }
17798
17799
4/4
✓ Branch 0 taken 156032 times.
✓ Branch 1 taken 8012 times.
✓ Branch 2 taken 8593 times.
✓ Branch 3 taken 147439 times.
164044 if(!DrunkUp() && !DrunkDown())
17800 {
17801
2/4
✓ Branch 0 taken 147439 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 147439 times.
147439 if(NO_GRIDLOCK)
17802 {
17803 int32_t v1=bigHitbox?0:8;
17804 int32_t v2=bigHitbox?8:12;
17805
17806 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
17807 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
17808 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
17809 {
17810 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17811 sprite::move((zfix)0,(zfix)-1);
17812 }
17813 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
17814 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
17815 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
17816 {
17817 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17818 sprite::move((zfix)0,(zfix)1);
17819 }
17820 else
17821 {
17822 pushing=push+1;
17823 }
17824 }
17825 147439 else pushing=push+1;
17826
17827
3/4
✓ Branch 0 taken 147433 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147433 times.
147439 if(charging==0 && spins==0)
17828 {
17829 147433 dir=left;
17830 147433 }
17831
17832
5/8
✓ Branch 0 taken 143644 times.
✓ Branch 1 taken 3795 times.
✓ Branch 2 taken 143644 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 143644 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 143644 times.
147439 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17833 {
17834 143644 herostep();
17835 143644 }
17836
17837 147439 return;
17838 }
17839 }
17840
17841 23946 return;
17842 }
17843
17844
2/2
✓ Branch 0 taken 2047297 times.
✓ Branch 1 taken 501774 times.
2549071 if(DrunkRight())
17845 {
17846
10/14
✓ Branch 0 taken 8228 times.
✓ Branch 1 taken 493546 times.
✓ Branch 2 taken 7619 times.
✓ Branch 3 taken 609 times.
✓ Branch 4 taken 7421 times.
✓ Branch 5 taken 198 times.
✓ Branch 6 taken 7421 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7421 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7421 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 7421 times.
501774 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17847 {
17848
4/4
✓ Branch 0 taken 7418 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 7409 times.
7421 if(dir!=left && dir!=right)
17849 {
17850
4/4
✓ Branch 0 taken 5268 times.
✓ Branch 1 taken 2141 times.
✓ Branch 2 taken 2234 times.
✓ Branch 3 taken 3034 times.
7409 if(yoff>2&&yoff<6)
17851 {
17852 3034 moveOld2(dir);
17853 3034 }
17854
2/2
✓ Branch 0 taken 2234 times.
✓ Branch 1 taken 2141 times.
4375 else if(yoff>=6)
17855 {
17856 2234 moveOld2(down);
17857 2234 }
17858
1/2
✓ Branch 0 taken 2141 times.
✗ Branch 1 not taken.
2141 else if(yoff>=1)
17859 {
17860 2141 moveOld2(up);
17861 2141 }
17862 7409 }
17863 else
17864 {
17865
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(yoff>=4)
17866 {
17867 6 moveOld2(down);
17868 6 }
17869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(yoff<4)
17870 {
17871 6 moveOld2(up);
17872 6 }
17873 }
17874 7421 }
17875 else
17876 {
17877 988706 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
17878 494353 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
17879
17880 494353 execute(info);
17881
17882
2/2
✓ Branch 0 taken 181171 times.
✓ Branch 1 taken 313182 times.
494353 if(!info.isUnwalkable())
17883 {
17884 313182 moveOld2(right);
17885 313182 return;
17886 }
17887
17888
4/4
✓ Branch 0 taken 174552 times.
✓ Branch 1 taken 6619 times.
✓ Branch 2 taken 8011 times.
✓ Branch 3 taken 166541 times.
181171 if(!DrunkUp() && !DrunkDown())
17889 {
17890
2/4
✓ Branch 0 taken 166541 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 166541 times.
166541 if(NO_GRIDLOCK)
17891 {
17892 int32_t v1=bigHitbox?0:8;
17893 int32_t v2=bigHitbox?8:12;
17894
17895 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
17896 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
17897 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
17898 {
17899 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17900 sprite::move((zfix)0,(zfix)-1);
17901 }
17902 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
17903 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
17904 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
17905 {
17906 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17907 sprite::move((zfix)0,(zfix)1);
17908 }
17909 else
17910 {
17911 pushing=push+1;
17912 }
17913 }
17914 166541 else pushing=push+1;
17915
17916
2/4
✓ Branch 0 taken 166541 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 166541 times.
166541 if(charging==0 && spins==0)
17917 {
17918 166541 dir=right;
17919 166541 }
17920
17921
5/8
✓ Branch 0 taken 164947 times.
✓ Branch 1 taken 1594 times.
✓ Branch 2 taken 164947 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 164947 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 164947 times.
166541 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17922 {
17923 164947 herostep();
17924 164947 }
17925
17926 166541 return;
17927 }
17928 }
17929 22051 }
17930 }
17931 13163999 }
17932
17933 4466262 bool HeroClass::scr_walkflag(zfix_round zdx,zfix_round zdy,int d2,bool kb, int* canladder)
17934 {
17935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4466262 times.
4466262 if(toogam) return false;
17936 4466262 int dx = zdx.getRound(), dy = zdy.getRound();
17937
17938
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4466262 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4466262 if(blockpath && dy<80) //Blocked top parts of rooms
17939 return true;
17940
17941
4/4
✓ Branch 0 taken 30097 times.
✓ Branch 1 taken 4436165 times.
✓ Branch 2 taken 18818 times.
✓ Branch 3 taken 11279 times.
4466262 if(mblock2.active() && mblock2.hit(dx,dy,0,1,1,1))
17942 11279 return true;
17943 //collide_object handled in scr_canmove
17944
17945
4/6
✓ Branch 0 taken 683926 times.
✓ Branch 1 taken 3771057 times.
✓ Branch 2 taken 683926 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4454983 times.
4478762 if(isdungeon() && currscr<128 && dy<40
17946
5/10
✓ Branch 0 taken 23779 times.
✓ Branch 1 taken 660147 times.
✓ Branch 2 taken 13692 times.
✓ Branch 3 taken 10087 times.
✓ Branch 4 taken 13692 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
683926 && ((x<=112||x>=128) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
17947
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
23779 && !get_qr(qr_FREEFORM))
17948 return true; //Old NES dungeon stuff
17949
17950
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4454983 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4454983 times.
4454983 bool solid = _walkflag(zdx,zdy,1,SWITCHBLOCK_STATE);
17951
17952
4/6
✓ Branch 0 taken 683926 times.
✓ Branch 1 taken 3771057 times.
✓ Branch 2 taken 683926 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 683926 times.
✗ Branch 5 not taken.
4454983 if(isdungeon() && currscr<128 && !get_qr(qr_FREEFORM))
17953 {
17954 if(dx>=112&&dx<120&&dy<40&&dy>=32)
17955 solid=true;
17956
17957 if(dx>=136&&dx<144&&dy<40&&dy>=32)
17958 solid=true;
17959 }
17960
17961
3/4
✓ Branch 0 taken 4418204 times.
✓ Branch 1 taken 36779 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4418204 times.
4454983 if(action==swimming || IsSideSwim())
17962 {
17963
2/2
✓ Branch 0 taken 13463 times.
✓ Branch 1 taken 23316 times.
36779 if(!solid)
17964 {
17965 23316 int ls = 22;
17966
1/6
✓ Branch 0 taken 23316 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
23316 if((get_qr(qr_DROWN) && isSwimming()) || (!diagonalMovement) || get_qr(qr_NO_HOPPING))
17967 23316 ls = 1;
17968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23316 times.
23316 if(landswim < ls)
17969 {
17970
2/4
✓ Branch 0 taken 23316 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23316 times.
23316 if(dx<0||dy<0);
17971
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 23296 times.
23316 else if(dx>=256);
17972
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 23278 times.
23296 else if(dy>=176);
17973
2/4
✓ Branch 0 taken 23278 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23278 times.
23278 else if(get_qr(qr_DROWN) && !ilswim);
17974 else if(iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17975 solid = false;
17976 else
17977 solid = true;
17978 23316 }
17979 23316 }
17980 else
17981 {
17982 13463 int32_t wtrx = iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy);
17983
17984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13463 times.
13463 if(wtrx)
17985 solid = false;
17986 }
17987 36779 }
17988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4418204 times.
4418204 else if(ladderx+laddery) // ladder is being used
17989 {
17990 if (canladder)
17991 {
17992 *canladder = 0;
17993 }
17994 int32_t lx = zfix(dx);
17995 int32_t ly = zfix(dy);
17996
17997 if(ladderdir<=down) //vertical ladder
17998 {
17999 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
18000 {
18001 bool temp = false;
18002
18003 if(!(abs(lx-(ladderx+8))<=8))
18004 temp = true;
18005
18006 if(!temp)
18007 {
18008 solid = false;
18009 }
18010 else if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
18011 {
18012 solid = true;
18013 }
18014 }
18015 }
18016 else //horizontal ladder
18017 {
18018 if(abs(lx-(ladderx+8))<=8)
18019 {
18020 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
18021 {
18022 solid = false;
18023 }
18024 else if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
18025 {
18026 solid = true;
18027 }
18028 else if((abs(ly-laddery+8)<=8) && d2<=down)
18029 {
18030 solid = false;
18031 }
18032 }
18033 }
18034 }
18035
5/6
✓ Branch 0 taken 2170631 times.
✓ Branch 1 taken 2247573 times.
✓ Branch 2 taken 2169359 times.
✓ Branch 3 taken 1272 times.
✓ Branch 4 taken 2169359 times.
✗ Branch 5 not taken.
4418204 else if(solid || isSideViewHero() || get_qr(qr_DROWN))
18036 {
18037 // see if it's a good spot for the ladder or for swimming
18038
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4418204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4418204 times.
4418204 bool unwalkablex = _walkflag(zdx,zdy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
18039
18040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4418204 times.
4418204 if(get_qr(qr_DROWN))
18041 {
18042 // Drowning changes the following attributes:
18043 // * Dangerous water is also walkable, so ignore the previous
18044 // definitions of unwalkablex.
18045 // * Instead, prevent the ladder from being used in the
18046 // one frame where Hero has landed on water before drowning.
18047 4418204 unwalkablex = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
18048 4418204 }
18049
18050 // check if he can swim
18051
4/6
✓ Branch 0 taken 431459 times.
✓ Branch 1 taken 3986745 times.
✓ Branch 2 taken 431459 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 431459 times.
4418204 if(current_item(itype_flippers) && z==0 && fakez==0)
18052 {
18053 431459 int32_t wtrx = iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy);
18054
5/6
✓ Branch 0 taken 431285 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 893 times.
✓ Branch 3 taken 430392 times.
✓ Branch 4 taken 893 times.
✗ Branch 5 not taken.
431459 if (current_item(itype_flippers) >= combobuf[wtrx].attribytes[0] && (!(combobuf[wtrx].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
18055 {
18056 //ladder ignores water combos that are now walkable thanks to flippers -DD
18057
2/2
✓ Branch 0 taken 4582 times.
✓ Branch 1 taken 426703 times.
431285 unwalkablex = unwalkablex && (!wtrx);
18058
18059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431285 times.
431285 if(landswim >= 22)
18060 {
18061 solid = false;
18062 }
18063
2/2
✓ Branch 0 taken 426943 times.
✓ Branch 1 taken 4342 times.
431285 else if(wtrx)
18064 {
18065
2/2
✓ Branch 0 taken 1000 times.
✓ Branch 1 taken 3342 times.
4342 if(dir==d2)
18066 {
18067 3342 ladderx = 0;
18068 3342 laddery = 0;
18069 3342 }
18070 4342 }
18071 431285 }
18072 431459 }
18073
18074 // check if he can use the ladder
18075 // "Allow Ladder Anywhere" is toggled by fLADDER
18076
1/2
✓ Branch 0 taken 4418204 times.
✗ Branch 1 not taken.
4418204 if(can_deploy_ladder())
18077 // laddersetup
18078 {
18079 // Check if there's water to use the ladder over
18080 bool wtrx = (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy) != 0);
18081 int32_t ldrid = current_item_id(itype_ladder);
18082 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
18083
18084 if(wtrx)
18085 {
18086 if(isSideViewHero())
18087 {
18088 wtrx = !_walkflag(zdx, zdy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(dx, dy, 1,SWITCHBLOCK_STATE) && dir!=down;
18089 }
18090 // * walk on half-water using the ladder instead of using flippers.
18091 // * otherwise, walk on ladder(+hookshot) combos.
18092 else if((isstepable(MAPCOMBO(dx, dy)) || wtrx==true))
18093 {
18094 if(!get_qr(qr_OLD_210_WATER) && current_item(itype_flippers))
18095 {
18096 //if Hero could swim on a tile instead of using the ladder,
18097 //refuse to use the ladder to step over that tile. -DD
18098 wtrx = isstepable(MAPCOMBO(dx, dy)) && unwalkablex;
18099 }
18100 }
18101 }
18102 else
18103 {
18104 // No water; check other things
18105
18106 //Check pits
18107 if(ladderpits)
18108 {
18109 int32_t pit_cmb = getpitfall(dx,dy);
18110 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
18111 }
18112 if(!ladderpits || (!wtrx || isSideViewHero())) //If no pit, check ladder combos
18113 {
18114 int32_t combo=combobuf[MAPCOMBO(dx, dy)].type;
18115 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
18116 }
18117 }
18118
18119 for (int32_t i = 0; i <= 1; ++i)
18120 {
18121 if(tmpscr2[i].valid!=0)
18122 {
18123 if (get_qr(qr_OLD_BRIDGE_COMBOS))
18124 {
18125 if (combobuf[MAPCOMBO2(i,dx,dy)].type == cBRIDGE && !_walkflag_layer(dx,dy,1, &(tmpscr2[i]))) wtrx = false;
18126 }
18127 else
18128 {
18129 if (combobuf[MAPCOMBO2(i,dx,dy)].type == cBRIDGE && _effectflag_layer(dx,dy,1, &(tmpscr2[i]))) wtrx = false;
18130 }
18131 }
18132 }
18133 bool walkwater = (get_qr(qr_DROWN) && !iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy));
18134
18135 if (!wtrx && solid)
18136 {
18137 if (canladder)
18138 {
18139 *canladder = 0;
18140 }
18141 }
18142
18143 if(d2==dir)
18144 {
18145 int32_t c = walkwater ? 0:8;
18146 int32_t b = walkwater ? 8:0;
18147
18148 if(d2>=left)
18149 {
18150 if (wtrx)
18151 {
18152 //If the difference between dy and y is small enough
18153 //this is apparently a really crappy corner shove check?
18154 if((replay_version_check(26)) || (abs((dy)-(int32_t(y+c)))<=(b)))
18155 {
18156 // Don't activate the ladder if it would be entirely
18157 // over water and Hero has the flippers. This isn't
18158 // a good way to do this, but it's too risky
18159 // to make big changes to this stuff.
18160 bool deployLadder=true;
18161 int32_t lx=dx&0xF0;
18162 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
18163 {
18164 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
18165 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
18166 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
18167 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
18168 deployLadder=false;
18169 }
18170 if(deployLadder)
18171 {
18172 if (replay_version_check(26))
18173 {
18174 if (canladder)
18175 {
18176 if (*canladder == -1) *canladder = 1;
18177 }
18178 }
18179 else
18180 {
18181 ladderx = dx&0xF0;
18182 laddery = y;
18183 ladderdir = left;
18184 ladderstart = d2;
18185 solid = laddery!=y.getInt();
18186 }
18187 }
18188 }
18189 }
18190 }
18191 else if(d2<=down)
18192 {
18193 if (wtrx)
18194 {
18195 //Unsure if this actually needs a replay check but better safe than sorry?
18196 if (replay_version_check(26))
18197 {
18198 if (canladder)
18199 {
18200 if (*canladder == -1) *canladder = 1;
18201 }
18202 }
18203 // If the difference between dx and x is small enough
18204 if(!replay_version_check(26) && (abs((dx)-(int32_t(x+c)))<=(b)))
18205 {
18206 ladderx = x;
18207 laddery = dy&0xF0;
18208 ladderdir = up;
18209 ladderstart = d2;
18210 solid = ladderx!=x.getInt();
18211 }
18212 }
18213 }
18214 }
18215 }
18216 4418204 }
18217
18218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4454983 times.
4454983 if (replay_version_check(26))
18219 {
18220
2/2
✓ Branch 0 taken 3236567 times.
✓ Branch 1 taken 1218416 times.
4454983 if (canladder)
18221 {
18222
3/4
✓ Branch 0 taken 1360225 times.
✓ Branch 1 taken 1876342 times.
✓ Branch 2 taken 1360225 times.
✗ Branch 3 not taken.
3236567 if (solid && *canladder == 1) *canladder = 2;
18223 3236567 }
18224 4454983 }
18225
18226 4454983 return solid;
18227 4466262 }
18228
18229 1473285 bool HeroClass::scr_canmove(zfix dx, zfix dy, bool kb, bool ign_sv, int* canladder)
18230 {
18231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1473285 times.
1473285 if(toogam) return true;
18232
3/4
✓ Branch 0 taken 716491 times.
✓ Branch 1 taken 756794 times.
✓ Branch 2 taken 716491 times.
✗ Branch 3 not taken.
1473285 if(!(dx || dy)) return true;
18233 1473285 zfix bx = x, by = y+(bigHitbox?0:8); //left/top
18234 1473285 zfix rx = x+15.9999_zf, ry = y+15.9999_zf; //right/bottom
18235 1473285 zfix wid = 16, hei = bigHitbox ? 16 : 8;
18236
5/14
✓ Branch 0 taken 1400878 times.
✓ Branch 1 taken 72407 times.
✓ Branch 2 taken 333685 times.
✓ Branch 3 taken 1067193 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 333685 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
1473285 if(!ign_sv && dy < 0 && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
18237 return false;
18238
18239 1473285 bool nosolid = true;
18240
18241 1473285 bool ret = true;
18242
18243
3/4
✓ Branch 0 taken 756794 times.
✓ Branch 1 taken 716491 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 756794 times.
1473285 if(dx && !dy)
18244 {
18245
2/2
✓ Branch 0 taken 351756 times.
✓ Branch 1 taken 405038 times.
756794 if(dx < 0)
18246 {
18247 351756 zfix mx = bx+dx;
18248
2/2
✓ Branch 0 taken 351756 times.
✓ Branch 1 taken 235577 times.
587333 for(zfix ty = 0; by+ty < ry; ty += 8)
18249 {
18250
2/2
✓ Branch 0 taken 209107 times.
✓ Branch 1 taken 142649 times.
351756 if(scr_walkflag(mx, by+ty, left, kb, canladder))
18251 {
18252
2/2
✓ Branch 0 taken 26470 times.
✓ Branch 1 taken 116179 times.
142649 if (canladder) ret = false;
18253 else
18254 {
18255 116179 return false;
18256 }
18257 26470 }
18258 235577 }
18259
2/2
✓ Branch 0 taken 48785 times.
✓ Branch 1 taken 186792 times.
235577 if(scr_walkflag(mx, ry, left, kb, canladder))
18260 48785 return false;
18261
2/2
✓ Branch 0 taken 182756 times.
✓ Branch 1 taken 4036 times.
186792 if (!ret) return false;
18262
2/4
✓ Branch 0 taken 182756 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182756 times.
✗ Branch 3 not taken.
182756 if(nosolid && collide_object(bx+dx,by,-dx,hei,this))
18263 return false;
18264 182756 }
18265 else
18266 {
18267 405038 zfix mx = rx+dx;
18268 405038 int lx = mx-hit_width+1;
18269
2/2
✓ Branch 0 taken 405038 times.
✓ Branch 1 taken 272141 times.
677179 for(zfix ty = 0; by+ty < ry; ty += 8)
18270 {
18271
2/2
✓ Branch 0 taken 235800 times.
✓ Branch 1 taken 169238 times.
405038 if(scr_walkflag(mx, by+ty, right, kb, canladder))
18272 {
18273
2/2
✓ Branch 0 taken 36341 times.
✓ Branch 1 taken 132897 times.
169238 if (canladder) ret = false;
18274 else
18275 {
18276 132897 return false;
18277 }
18278 36341 }
18279 272141 }
18280
2/2
✓ Branch 0 taken 72956 times.
✓ Branch 1 taken 199185 times.
272141 if(scr_walkflag(mx, ry, right, kb, canladder))
18281 72956 return false;
18282
2/2
✓ Branch 0 taken 191739 times.
✓ Branch 1 taken 7446 times.
199185 if (!ret) return false;
18283
2/4
✓ Branch 0 taken 191739 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191739 times.
✗ Branch 3 not taken.
191739 if(nosolid && collide_object(bx+wid,by,dx,hei,this))
18284 return false;
18285 }
18286 374495 }
18287
2/4
✓ Branch 0 taken 716491 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 716491 times.
716491 else if(dy && !dx)
18288 {
18289
2/2
✓ Branch 0 taken 343209 times.
✓ Branch 1 taken 373282 times.
716491 if(dy < 0)
18290 {
18291 343209 zfix my = by+dy;
18292
2/2
✓ Branch 0 taken 595337 times.
✓ Branch 1 taken 232679 times.
828016 for(zfix tx = 0; bx+tx < rx; tx += 8)
18293 {
18294
2/2
✓ Branch 0 taken 365626 times.
✓ Branch 1 taken 229711 times.
595337 if(scr_walkflag(bx+tx, my, up, kb, canladder))
18295 {
18296
2/2
✓ Branch 0 taken 119181 times.
✓ Branch 1 taken 110530 times.
229711 if (canladder) ret = false;
18297 else
18298 {
18299 110530 return false;
18300 }
18301 119181 }
18302 484807 }
18303
2/2
✓ Branch 0 taken 76623 times.
✓ Branch 1 taken 156056 times.
232679 if(scr_walkflag(rx, my, up, kb, canladder))
18304 76623 return false;
18305
2/2
✓ Branch 0 taken 140293 times.
✓ Branch 1 taken 15763 times.
156056 if (!ret) return false;
18306
2/4
✓ Branch 0 taken 140293 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140293 times.
✗ Branch 3 not taken.
140293 if(nosolid && collide_object(bx,by+dy,wid,-dy,this))
18307 return false;
18308 140293 }
18309 else
18310 {
18311 373282 zfix my = ry+dy;
18312 373282 int ly = my-hit_height+1;
18313
2/2
✓ Branch 0 taken 612531 times.
✓ Branch 1 taken 211578 times.
824109 for(zfix tx = 0; bx+tx < rx; tx += 8)
18314 {
18315
2/2
✓ Branch 0 taken 401423 times.
✓ Branch 1 taken 211108 times.
612531 if(scr_walkflag(bx+tx, my, down, kb, canladder))
18316 {
18317
2/2
✓ Branch 0 taken 49404 times.
✓ Branch 1 taken 161704 times.
211108 if (canladder) ret = false;
18318 else
18319 {
18320 161704 return false;
18321 }
18322 49404 }
18323 450827 }
18324
2/2
✓ Branch 0 taken 60032 times.
✓ Branch 1 taken 151546 times.
211578 if(scr_walkflag(rx, my, down, kb, canladder))
18325 60032 return false;
18326
2/2
✓ Branch 0 taken 144737 times.
✓ Branch 1 taken 6809 times.
151546 if (!ret) return false;
18327
2/4
✓ Branch 0 taken 144737 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144737 times.
144737 if(nosolid && collide_object(bx,by+hei,wid,dy,this))
18328 return false;
18329 }
18330 285030 }
18331 else //! Untested, and currently unused.
18332 {
18333 return scr_canmove(dx, 0, kb, ign_sv) && scr_canmove(dy, 0, kb, ign_sv);
18334 }
18335 659525 return ret;
18336 1473285 }
18337 444360 bool handle_movestate(std::function<bool()> proc)
18338 {
18339 444360 zfix ox = Hero.x, oy = Hero.y;
18340 444360 auto oladderx = Hero.ladderx;
18341 444360 auto oladdery = Hero.laddery;
18342 444360 auto oladderdir = Hero.ladderdir;
18343 444360 auto oladderstart = Hero.ladderstart;
18344
18345 444360 bool ret = proc();
18346
18347 444360 Hero.x = ox;
18348 444360 Hero.y = oy;
18349 444360 Hero.ladderx = oladderx;
18350 444360 Hero.laddery = oladdery;
18351 444360 Hero.ladderdir = oladderdir;
18352 444360 Hero.ladderstart = oladderstart;
18353
18354 444360 return ret;
18355 }
18356
18357 70 zfix handle_movestate_zfix(std::function<zfix()> proc)
18358 {
18359 70 zfix ox = Hero.x, oy = Hero.y;
18360 70 auto oladderx = Hero.ladderx;
18361 70 auto oladdery = Hero.laddery;
18362 70 auto oladderdir = Hero.ladderdir;
18363 70 auto oladderstart = Hero.ladderstart;
18364
18365 70 zfix ret = proc();
18366
18367 70 Hero.x = ox;
18368 70 Hero.y = oy;
18369 70 Hero.ladderx = oladderx;
18370 70 Hero.laddery = oladdery;
18371 70 Hero.ladderdir = oladderdir;
18372 70 Hero.ladderstart = oladderstart;
18373
18374 70 return ret;
18375 }
18376
18377 53377 optional<zfix> HeroClass::get_solid_coord(zfix tx, zfix ty, byte dir, byte mdir, bool kb, zfix earlyterm, bool doladder)
18378 {
18379 53377 zfix tmp;
18380
4/5
✓ Branch 0 taken 4627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9243 times.
✓ Branch 3 taken 21111 times.
✓ Branch 4 taken 18396 times.
53377 switch(dir)
18381 {
18382 default:
18383 case up:
18384
2/4
✓ Branch 0 taken 4627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4627 times.
✗ Branch 3 not taken.
84684 tmp = binary_search_zfix(ty, earlyterm, [&](zfix ty, zfix& retval)
18385 {
18386 80057 int laddercheck = -1;
18387
2/2
✓ Branch 0 taken 40197 times.
✓ Branch 1 taken 39860 times.
80057 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18388 {
18389 40197 retval = ty;
18390 40197 return BSEARCH_CONTINUE_UP;
18391 }
18392
2/4
✓ Branch 0 taken 39860 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 39860 times.
39860 else if(doladder && laddercheck > 0)
18393 {
18394 retval = ty;
18395 return BSEARCH_CONTINUE_UP;
18396 }
18397 39860 else return BSEARCH_CONTINUE_DOWN;
18398
1/2
✓ Branch 0 taken 4627 times.
✗ Branch 1 not taken.
84684 }, -999);
18399
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 4222 times.
4627 if(tmp > -999)
18400 4222 tmp -= 15.9999_zf;
18401 4627 break;
18402 case down:
18403
2/4
✓ Branch 0 taken 9243 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9243 times.
✗ Branch 3 not taken.
171090 tmp = binary_search_zfix(ty, earlyterm, [&](zfix ty, zfix& retval)
18404 {
18405 161847 int laddercheck = -1;
18406
2/2
✓ Branch 0 taken 68573 times.
✓ Branch 1 taken 93274 times.
161847 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18407 {
18408 68573 retval = ty;
18409 68573 return BSEARCH_CONTINUE_DOWN;
18410 }
18411
2/4
✓ Branch 0 taken 93274 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93274 times.
93274 else if(doladder && laddercheck > 0)
18412 {
18413 retval = ty;
18414 return BSEARCH_CONTINUE_DOWN;
18415 }
18416 93274 else return BSEARCH_CONTINUE_UP;
18417
1/2
✓ Branch 0 taken 9243 times.
✗ Branch 1 not taken.
171090 }, -999);
18418
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 8919 times.
9243 if(tmp > -999)
18419 8919 tmp -= (bigHitbox?0:8);
18420 9243 break;
18421 case left:
18422
2/4
✓ Branch 0 taken 21111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21111 times.
✗ Branch 3 not taken.
395076 tmp = binary_search_zfix(tx, earlyterm, [&](zfix tx, zfix& retval)
18423 {
18424 373965 int laddercheck = -1;
18425
2/2
✓ Branch 0 taken 53414 times.
✓ Branch 1 taken 320551 times.
373965 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18426 {
18427 53414 retval = tx;
18428 53414 return BSEARCH_CONTINUE_UP;
18429 }
18430
2/4
✓ Branch 0 taken 320551 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 320551 times.
320551 else if(doladder && laddercheck > 0)
18431 {
18432 retval = tx;
18433 return BSEARCH_CONTINUE_UP;
18434 }
18435 320551 else return BSEARCH_CONTINUE_DOWN;
18436
1/2
✓ Branch 0 taken 21111 times.
✗ Branch 1 not taken.
395076 }, -999);
18437
2/2
✓ Branch 0 taken 15280 times.
✓ Branch 1 taken 5831 times.
21111 if(tmp > -999)
18438 5831 tmp -= 15.9999_zf;
18439 21111 break;
18440 case right:
18441
2/4
✓ Branch 0 taken 18396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18396 times.
✗ Branch 3 not taken.
345652 tmp = binary_search_zfix(tx, earlyterm, [&](zfix tx, zfix& retval)
18442 {
18443 327256 int laddercheck = -1;
18444
2/2
✓ Branch 0 taken 38219 times.
✓ Branch 1 taken 289037 times.
327256 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18445 {
18446 38219 retval = tx;
18447 38219 return BSEARCH_CONTINUE_DOWN;
18448 }
18449
2/4
✓ Branch 0 taken 289037 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 289037 times.
289037 else if(doladder && laddercheck > 0)
18450 {
18451 retval = tx;
18452 return BSEARCH_CONTINUE_DOWN;
18453 }
18454 289037 else return BSEARCH_CONTINUE_UP;
18455
1/2
✓ Branch 0 taken 18396 times.
✗ Branch 1 not taken.
345652 }, -999);
18456 18396 break;
18457 }
18458
2/2
✓ Branch 0 taken 29908 times.
✓ Branch 1 taken 23469 times.
53377 if(tmp > -999)
18459 {
18460 23469 zfix tx2(x), ty2(y);
18461 23469 zfix dx, dy;
18462
4/5
✓ Branch 0 taken 4222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5831 times.
✓ Branch 3 taken 4497 times.
✓ Branch 4 taken 8919 times.
23469 switch(dir)
18463 {
18464 case left:
18465 5831 tx2 = tmp;
18466 5831 break;
18467 case right:
18468 4497 tx2 = tmp;
18469 4497 break;
18470 default:
18471 case up:
18472 4222 ty2 = tmp;
18473 4222 break;
18474 case down:
18475 8919 ty2 = tmp;
18476 8919 break;
18477 }
18478
4/5
✓ Branch 0 taken 4882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4110 times.
✓ Branch 3 taken 9031 times.
✓ Branch 4 taken 5446 times.
23469 switch(mdir)
18479 {
18480 case left:
18481 4110 dx = -0.0001_zf;
18482 4110 break;
18483 case right:
18484 9031 dx = 0.0001_zf;
18485 9031 break;
18486 default:
18487 case up:
18488 4882 dy = -0.0001_zf;
18489 4882 break;
18490 case down:
18491 5446 dy = 0.0001_zf;
18492 5446 break;
18493 }
18494 23469 zfix oldx(x), oldy(y);
18495 23469 x = tx2;
18496 23469 y = ty2;
18497 23469 int laddercheck = -1;
18498 23469 bool valid = scr_canmove(dx, dy, kb, true, &laddercheck);
18499
1/2
✓ Branch 0 taken 23469 times.
✗ Branch 1 not taken.
23469 if (laddercheck > 0) valid = true;
18500 23469 x = oldx;
18501 23469 y = oldy;
18502
2/2
✓ Branch 0 taken 23419 times.
✓ Branch 1 taken 50 times.
23469 if(valid)
18503 23419 return tmp;
18504 50 }
18505 29958 return std::nullopt;
18506 53377 }
18507
18508 721234 bool HeroClass::movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove, bool earlyret)
18509 {
18510 721234 bool ret = true;
18511 721234 int ladderstuff = -1;
18512
3/10
✓ Branch 0 taken 696765 times.
✓ Branch 1 taken 24469 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 696765 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
721234 bool sv = !ign_sv && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking;
18513
1/2
✓ Branch 0 taken 721234 times.
✗ Branch 1 not taken.
721234 if(sv)
18514 dy = 0;
18515
4/4
✓ Branch 0 taken 420622 times.
✓ Branch 1 taken 300612 times.
✓ Branch 2 taken 355105 times.
✓ Branch 3 taken 65517 times.
721234 if(dx && dy)
18516 65517 shove = false;
18517 721234 bool checkladder = dy < 0;
18518
18519 721234 const int scl = 2;
18520
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 721290 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 721234 times.
721304 while(abs(dx) > scl || abs(dy) > scl)
18521 {
18522
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 56 times.
70 if(abs(dx) > abs(dy))
18523 {
18524 14 int32_t tdx = dx.sign() * scl;
18525
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(movexy(tdx, 0, kb, ign_sv, shove, earlyret))
18526 14 dx -= tdx;
18527 else
18528 {
18529 if(earlyret) return false;
18530 dx = tdx;
18531 ret = false;
18532 }
18533 14 }
18534 else
18535 {
18536 56 int32_t tdy = dy.sign() * scl;
18537
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(movexy(0, tdy, kb, ign_sv, shove, earlyret))
18538 56 dy -= tdy;
18539 else
18540 {
18541 if(earlyret) return false;
18542 dy = tdy;
18543 ret = false;
18544 }
18545 }
18546 }
18547
18548
10/12
✓ Branch 0 taken 276734 times.
✓ Branch 1 taken 444500 times.
✓ Branch 2 taken 23182 times.
✓ Branch 3 taken 253552 times.
✓ Branch 4 taken 23182 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 556 times.
✓ Branch 7 taken 22626 times.
✓ Branch 8 taken 22526 times.
✓ Branch 9 taken 100 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 22526 times.
721234 bool skipdmg = earlyret || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS));
18549
2/2
✓ Branch 0 taken 300612 times.
✓ Branch 1 taken 420622 times.
721234 if(dx)
18550 {
18551
2/2
✓ Branch 0 taken 350219 times.
✓ Branch 1 taken 70403 times.
420622 if(scr_canmove(dx, 0, kb, ign_sv, &ladderstuff))
18552 {
18553
1/2
✓ Branch 0 taken 350219 times.
✗ Branch 1 not taken.
350219 if (ladderstuff == 1)
18554 {
18555 zfix tx = (dx < 0 ? (x+dx) : (x+8+dx));
18556 zfix tx2 = (dx < 0 ? 15 : 0);
18557 zfix tx3 = (dx < 0 ? -8 : 8);
18558 ladderx = tx.getInt()&0xF8;
18559 laddery = y.getTrunc();
18560 if (((iswaterex(MAPCOMBO(ladderx+tx2,y+9), currmap, currscr, -1, ladderx+tx2,y+9) != 0) || getpitfall(ladderx+tx2,y+9))
18561 && ((iswaterex(MAPCOMBO(ladderx+tx2,y+15), currmap, currscr, -1, ladderx+tx2,y+15) != 0) || getpitfall(ladderx+tx2,y+15)))
18562 {
18563 ladderdir = left;
18564 ladderstart = dir;
18565 }
18566 else if (((iswaterex(MAPCOMBO(ladderx+tx2+tx3,y+9), currmap, currscr, -1, ladderx+tx2+tx3,y+9) != 0) || getpitfall(ladderx+tx2+tx3,y+9))
18567 && ((iswaterex(MAPCOMBO(ladderx+tx2+tx3,y+15), currmap, currscr, -1, ladderx+tx2+tx3,y+15) != 0) || getpitfall(ladderx+tx2+tx3,y+15)))
18568 {
18569 ladderx = (tx.getInt()+tx3.getInt())&0xF8;
18570 ladderdir = left;
18571 ladderstart = dir;
18572 }
18573 else
18574 {
18575 ladderx = 0;
18576 laddery = 0;
18577 }
18578 }
18579
1/2
✓ Branch 0 taken 350219 times.
✗ Branch 1 not taken.
350219 if (ladderstuff > 0) ladderstuff = 0;
18580 350219 x += dx;
18581 350219 }
18582 else
18583 {
18584 70403 bool stopped = true;
18585 70403 bool shoved = false;
18586
2/2
✓ Branch 0 taken 10934 times.
✓ Branch 1 taken 59469 times.
70403 if(shove)
18587 {
18588
2/2
✓ Branch 0 taken 24467 times.
✓ Branch 1 taken 35002 times.
59469 zfix tx = (dx < 0 ? (x-4) : (x+20));
18589 59469 int v=bigHitbox?0:8;
18590 59469 zfix ly = y+v;
18591 59469 zfix ry = y+15.9999_zf;
18592 59469 zfix ly2 = y+v+6;
18593 59469 zfix ry2 = y+9.9999_zf;
18594 59469 auto mdir = GET_XDIR(dx);
18595 59469 int laddershove = -1;
18596 59469 int ladderhit = 0;
18597 59469 bool onladder = (ladderx + laddery);
18598 59469 bool hit_top = scr_walkflag(tx,ly,mdir,false, &laddershove);
18599
1/2
✓ Branch 0 taken 59469 times.
✗ Branch 1 not taken.
59469 if (laddershove > 0)
18600 {
18601 hit_top = false;
18602 ladderhit += 1;
18603 }
18604 59469 laddershove = -1;
18605 59469 bool hit_bottom = scr_walkflag(tx,ry,mdir,false, &laddershove);
18606
1/2
✓ Branch 0 taken 59469 times.
✗ Branch 1 not taken.
59469 if (laddershove > 0)
18607 {
18608 hit_bottom = false;
18609 ladderhit += 2;
18610 }
18611 59469 laddershove = -1;
18612 59469 bool hit_top2 = scr_walkflag(tx,ly2,mdir,false);
18613 59469 bool hit_bottom2 = scr_walkflag(tx,ry2,mdir,false);
18614
3/4
✓ Branch 0 taken 4744 times.
✓ Branch 1 taken 54725 times.
✓ Branch 2 taken 4744 times.
✗ Branch 3 not taken.
59469 if (!hit_top && ladderhit == 2)
18615 {
18616 hit_bottom = true;
18617 }
18618
3/4
✓ Branch 0 taken 9360 times.
✓ Branch 1 taken 50109 times.
✓ Branch 2 taken 9360 times.
✗ Branch 3 not taken.
59469 if (!hit_bottom && ladderhit == 1)
18619 {
18620 hit_top = true;
18621 }
18622
2/2
✓ Branch 0 taken 45599 times.
✓ Branch 1 taken 13870 times.
59469 if(hit_top!=hit_bottom)
18623 {
18624
2/2
✓ Branch 0 taken 4627 times.
✓ Branch 1 taken 9243 times.
13870 if(hit_bottom) //shove up
18625 {
18626
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4627 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4627 if (onladder && (ladderdir == left || ladderdir == right) && !hit_bottom2)
18627 {
18628 y -= 1_zf;
18629 shoved = true;
18630 }
18631
4/6
✓ Branch 0 taken 4613 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4627 times.
4627 else if(skipdmg || !checkdamagecombos(tx,get_qr(qr_SENSITIVE_SOLID_DAMAGE)?int32_t(y+15):(v+bigHitbox?11:4)))
18632 {
18633
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 4218 times.
4627 if(optional<zfix> ty = get_solid_coord(tx,ry,up,mdir,false,ry-shove_offset, (ladderhit != 2)))
18634 {
18635
2/2
✓ Branch 0 taken 1023 times.
✓ Branch 1 taken 3195 times.
4218 zfix dy = zc_max(-1_zf,*ty-y);
18636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4218 times.
4218 if((shoved = dy))
18637 4218 movexy(0, dy, kb, true, false, false);
18638 4218 }
18639 4627 }
18640 4627 }
18641 else //shove down
18642 {
18643
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9243 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9243 if (onladder && (ladderdir == left || ladderdir == right) && !hit_top2)
18644 {
18645 y += 1_zf;
18646 shoved = true;
18647 }
18648
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
9243 else if(skipdmg || !checkdamagecombos(tx,v+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
18649 {
18650
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 8919 times.
9243 if(optional<zfix> ty = get_solid_coord(tx,ly,down,mdir,false,ly+shove_offset, (ladderhit != 1)))
18651 {
18652
2/2
✓ Branch 0 taken 8286 times.
✓ Branch 1 taken 633 times.
8919 zfix dy = zc_min(1_zf,*ty-y);
18653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8919 times.
8919 if((shoved = dy))
18654 8919 movexy(0, dy, kb, true, false, false);
18655 8919 }
18656 9243 }
18657 }
18658
18659
4/4
✓ Branch 0 taken 13137 times.
✓ Branch 1 taken 733 times.
✓ Branch 2 taken 11366 times.
✓ Branch 3 taken 1771 times.
13870 if(shoved && scr_canmove(dx, 0, kb, ign_sv))
18660 {
18661 1771 x += dx;
18662 1771 stopped = false;
18663 1771 }
18664 13870 }
18665 59469 }
18666
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 68632 times.
70403 if(stopped)
18667 {
18668
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 68632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
68632 if (ladderstuff > 0 && !shoved)
18669 {
18670 zfix tx = (dx < 0 ? (x-12) : (x+20));
18671 ladderx = tx.getInt()&0xF8;
18672 laddery = y.getTrunc();
18673 ladderdir = left;
18674 ladderstart = dir;
18675 x += dx;
18676 ladderstuff = 0;
18677 }
18678
2/2
✓ Branch 0 taken 48997 times.
✓ Branch 1 taken 19635 times.
68632 else if(earlyret)
18679 {
18680 48997 ret = false;
18681 48997 }
18682 else
18683 {
18684 19635 ret = false;
18685 19635 int xsign = dx.sign();
18686
2/2
✓ Branch 0 taken 1854 times.
✓ Branch 1 taken 17781 times.
19635 if(abs(dx) > 1)
18687 {
18688
2/2
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 17781 times.
18246 while(scr_canmove(xsign, 0, kb, ign_sv))
18689 {
18690 465 x += xsign;
18691 465 dx -= xsign;
18692 }
18693 17781 }
18694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19635 times.
19635 if(dx)
18695 {
18696 19635 dx.doDecBound(0,-9999, 0,9999);
18697
3/6
✓ Branch 0 taken 19635 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19635 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19635 times.
✗ Branch 5 not taken.
311269 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
18698
2/2
✓ Branch 0 taken 8889 times.
✓ Branch 1 taken 282745 times.
291634 if(scr_canmove(val, 0, kb, ign_sv))
18699 {
18700 8889 retval = val;
18701 8889 return BSEARCH_CONTINUE_AWAY0;
18702 }
18703 282745 else return BSEARCH_CONTINUE_TOWARD0;
18704 291634 });
18705 19635 x += dx;
18706 19635 }
18707 }
18708 68632 }
18709 }
18710 420622 }
18711 721234 ladderstuff = -1;
18712
2/2
✓ Branch 0 taken 356063 times.
✓ Branch 1 taken 365171 times.
721234 if(dy)
18713 {
18714
2/2
✓ Branch 0 taken 260923 times.
✓ Branch 1 taken 104248 times.
365171 if(scr_canmove(0, dy, kb, ign_sv, &ladderstuff))
18715 {
18716
1/2
✓ Branch 0 taken 260923 times.
✗ Branch 1 not taken.
260923 if (ladderstuff == 1)
18717 {
18718 zfix ty = (dy < 0 ? (y+(bigHitbox?0:8)+dy) : (y+8+dy));
18719 zfix ty2 = (dy < 0 ? 15 : 0);
18720 zfix ty3 = (dy < 0 ? -8 : 8);
18721
18722 ladderx = x.getTrunc();
18723 laddery = ty.getInt()&0xF8;
18724 if (((iswaterex(MAPCOMBO(x+4,laddery+ty2), currmap, currscr, -1, x+4,laddery+ty2) != 0) || getpitfall(x+4,laddery+ty2))
18725 && ((iswaterex(MAPCOMBO(x+11,laddery+ty2), currmap, currscr, -1, x+11,laddery+ty2) != 0) || getpitfall(x+11,laddery+ty2)))
18726 {
18727 ladderdir = up;
18728 ladderstart = dir;
18729 }
18730 else if (((iswaterex(MAPCOMBO(x+4,laddery+ty2+ty3), currmap, currscr, -1, x+4,laddery+ty2+ty3) != 0) || getpitfall(x+4,laddery+ty2+ty3))
18731 && ((iswaterex(MAPCOMBO(x+11,laddery+ty2+ty3), currmap, currscr, -1, x+11,laddery+ty2+ty3) != 0) || getpitfall(x+11,laddery+ty2+ty3)))
18732 {
18733 laddery = (ty.getInt() + ty3.getInt())&0xF8;
18734 ladderdir = up;
18735 ladderstart = dir;
18736 }
18737 else
18738 {
18739 ladderx = 0;
18740 laddery = 0;
18741 }
18742 }
18743
1/2
✓ Branch 0 taken 260923 times.
✗ Branch 1 not taken.
260923 if (ladderstuff > 0) ladderstuff = 0;
18744 260923 y += dy;
18745 260923 }
18746 else
18747 {
18748 104248 bool stopped = true;
18749 104248 bool shoved = false;
18750
2/2
✓ Branch 0 taken 12092 times.
✓ Branch 1 taken 92156 times.
104248 if(shove)
18751 {
18752
2/2
✓ Branch 0 taken 66475 times.
✓ Branch 1 taken 25681 times.
92156 zfix ty = (dy < 0 ? (y+(bigHitbox?0:8)-4) : (y+20));
18753 92156 zfix lx = x;
18754 92156 zfix rx = x+15.9999_zf;
18755 92156 zfix lx2 = x+6;
18756 92156 zfix rx2 = x+9.9999_zf;
18757 92156 auto mdir = GET_YDIR(dy);
18758 92156 int laddershove = -1;
18759 92156 int ladderhit = 0;
18760 92156 bool onladder = (ladderx + laddery);
18761 92156 bool hit_left = scr_walkflag(lx,ty,mdir,false, &laddershove);
18762
1/2
✓ Branch 0 taken 92156 times.
✗ Branch 1 not taken.
92156 if (laddershove > 0)
18763 {
18764 hit_left = false;
18765 ladderhit += 1;
18766 }
18767 92156 laddershove = -1;
18768 92156 bool hit_right = scr_walkflag(rx,ty,mdir,false, &laddershove);
18769
1/2
✓ Branch 0 taken 92156 times.
✗ Branch 1 not taken.
92156 if (laddershove > 0)
18770 {
18771 hit_right = false;
18772 ladderhit += 2;
18773 }
18774 92156 bool hit_left2 = scr_walkflag(lx2,ty,mdir,false);
18775 92156 bool hit_right2 = scr_walkflag(rx2,ty,mdir,false);
18776 92156 laddershove = -1;
18777
3/4
✓ Branch 0 taken 21285 times.
✓ Branch 1 taken 70871 times.
✓ Branch 2 taken 21285 times.
✗ Branch 3 not taken.
92156 if (!hit_left && ladderhit == 2)
18778 {
18779 hit_right = true;
18780 }
18781
3/4
✓ Branch 0 taken 18570 times.
✓ Branch 1 taken 73586 times.
✓ Branch 2 taken 18570 times.
✗ Branch 3 not taken.
92156 if (!hit_right && ladderhit == 1)
18782 {
18783 hit_left = true;
18784 }
18785
2/2
✓ Branch 0 taken 52649 times.
✓ Branch 1 taken 39507 times.
92156 if(hit_left!=hit_right)
18786 {
18787
2/2
✓ Branch 0 taken 21111 times.
✓ Branch 1 taken 18396 times.
39507 if(hit_right) //shove left
18788 {
18789
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21111 if (onladder && ladderdir <= down && !hit_right2)
18790 {
18791 x -= 1_zf;
18792 shoved = true;
18793 }
18794
3/4
✓ Branch 0 taken 21106 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21111 times.
21111 else if(skipdmg || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),ty))
18795 {
18796
2/2
✓ Branch 0 taken 15280 times.
✓ Branch 1 taken 5831 times.
21111 if(optional<zfix> tx = get_solid_coord(rx,ty,left,mdir,false,rx-shove_offset, (ladderhit != 2)))
18797 {
18798
2/2
✓ Branch 0 taken 4391 times.
✓ Branch 1 taken 1440 times.
5831 zfix dx = zc_max(-1_zf,*tx-x);
18799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5831 times.
5831 if((shoved = dx))
18800 5831 movexy(dx, 0, kb, true, false, false);
18801 5831 }
18802 21111 }
18803 21111 }
18804 else //shove right
18805 {
18806
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18396 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18396 if (onladder && ladderdir <= down && !hit_left2)
18807 {
18808 x += 1_zf;
18809 shoved = true;
18810 }
18811
3/4
✓ Branch 0 taken 18393 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18396 times.
18396 else if(skipdmg || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),ty))
18812 {
18813
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 4451 times.
18396 if(optional<zfix> tx = get_solid_coord(lx,ty,right,mdir,false,lx+shove_offset, (ladderhit != 1)))
18814 {
18815
2/2
✓ Branch 0 taken 1671 times.
✓ Branch 1 taken 2780 times.
4451 zfix dx = zc_min(1_zf,*tx-x);
18816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4451 times.
4451 if((shoved = dx))
18817 4451 movexy(dx, 0, kb, true, false, false);
18818 4451 }
18819 18396 }
18820 }
18821
18822
4/4
✓ Branch 0 taken 10282 times.
✓ Branch 1 taken 29225 times.
✓ Branch 2 taken 6903 times.
✓ Branch 3 taken 3379 times.
39507 if(shoved && scr_canmove(0, dy, kb, ign_sv))
18823 {
18824 3379 y += dy;
18825 3379 stopped = false;
18826 3379 }
18827 39507 }
18828 92156 }
18829
2/2
✓ Branch 0 taken 3379 times.
✓ Branch 1 taken 100869 times.
104248 if(stopped)
18830 {
18831
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 100869 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
100869 if (ladderstuff > 0 && !shoved)
18832 {
18833 zfix ty = (dy < 0 ? (y-(bigHitbox?12:4)) : (y+20));
18834 ladderx = x.getTrunc();
18835 laddery = ty.getInt()&0xF8;
18836 ladderdir = up;
18837 ladderstart = dir;
18838 y += dy;
18839 ladderstuff = 0;
18840 }
18841 else
18842 {
18843
2/2
✓ Branch 0 taken 79867 times.
✓ Branch 1 taken 21002 times.
100869 if(earlyret) return false;
18844 21002 ret = false;
18845 21002 int ysign = dy.sign();
18846
2/2
✓ Branch 0 taken 2784 times.
✓ Branch 1 taken 18218 times.
21002 if(abs(dy) > 1)
18847 {
18848
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 18218 times.
18557 while(scr_canmove(0, ysign, kb, ign_sv))
18849 {
18850 339 y += ysign;
18851 339 dy -= ysign;
18852 }
18853 18218 }
18854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21002 times.
21002 if(dy)
18855 {
18856 21002 dy.doDecBound(0,-9999, 0,9999);
18857
3/6
✓ Branch 0 taken 21002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21002 times.
✗ Branch 5 not taken.
333099 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
18858
2/2
✓ Branch 0 taken 10051 times.
✓ Branch 1 taken 302046 times.
312097 if(scr_canmove(0, val, kb, ign_sv))
18859 {
18860 10051 retval = val;
18861 10051 return BSEARCH_CONTINUE_AWAY0;
18862 }
18863 302046 else return BSEARCH_CONTINUE_TOWARD0;
18864 312097 });
18865 21002 y += dy;
18866 21002 }
18867 }
18868 21002 }
18869 }
18870 285304 }
18871
18872
2/2
✓ Branch 0 taken 364633 times.
✓ Branch 1 taken 276734 times.
641367 if(earlyret)
18873 364633 return ret;
18874
5/10
✓ Branch 0 taken 64233 times.
✓ Branch 1 taken 212501 times.
✓ Branch 2 taken 60045 times.
✓ Branch 3 taken 4188 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60045 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
276734 if(dy < 0 && !ign_sv && sideview_mode() && IsSideSwim() && checkladder)
18875 {
18876 if(!iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-2), currmap, currscr, -1, x, y+(bigHitbox?0:8) - 2, true, false)
18877 && !canSideviewLadderRemote(x, y-4) && scr_canmove(0, -2, kb, true) && (y+(bigHitbox?0:8) - 4) > 0)
18878 {
18879 if (game->get_sideswim_jump() != 0)
18880 {
18881 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
18882 sfx(WAV_ZN1SPLASH,(int32_t)x);
18883 hopclk = 0;
18884 if (charging || spins) action = attacking;
18885 else action = none;
18886 }
18887 else
18888 {
18889 movexy(0,-1*dy,false,false,false);
18890 }
18891 }
18892 }
18893 276734 return ret;
18894 721234 }
18895 3596 bool HeroClass::can_movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove)
18896 {
18897
1/2
✓ Branch 0 taken 3596 times.
✗ Branch 1 not taken.
7192 return handle_movestate([&]()
18898 {
18899 3596 return movexy(dx,dy,kb,ign_sv,shove,true);
18900 });
18901 }
18902 bool HeroClass::moveAtAngle(zfix degrees, zfix px, bool kb, bool ign_sv, bool shove, bool earlyret)
18903 {
18904 double v = degrees.getFloat() * PI / 180.0;
18905 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
18906 return movexy(dx, dy, kb, ign_sv, shove, earlyret);
18907 }
18908 bool HeroClass::can_moveAtAngle(zfix degrees, zfix px, bool kb, bool ign_sv, bool shove)
18909 {
18910 return handle_movestate([&]()
18911 {
18912 return moveAtAngle(degrees,px,kb,ign_sv,shove,true);
18913 });
18914 }
18915 440764 bool HeroClass::moveDir(int dir, zfix px, bool kb, bool ign_sv, bool shove, bool earlyret)
18916 {
18917
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 440762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
440764 static const zfix diagrate = zslongToFix(7071);
18918
6/13
✓ Branch 0 taken 440764 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 440764 times.
✓ Branch 4 taken 128017 times.
✓ Branch 5 taken 84306 times.
✓ Branch 6 taken 110138 times.
✓ Branch 7 taken 118303 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
440764 switch(NORMAL_DIR(dir))
18919 {
18920 case up:
18921 128017 return movexy(0, -px, kb, ign_sv, shove, earlyret);
18922 case down:
18923 84306 return movexy(0, px, kb, ign_sv, shove, earlyret);
18924 case left:
18925 110138 return movexy(-px, 0, kb, ign_sv, shove, earlyret);
18926 case right:
18927 118303 return movexy(px, 0, kb, ign_sv, shove, earlyret);
18928 case r_up:
18929 return movexy(px*diagrate, -px*diagrate, kb, ign_sv, shove, earlyret);
18930 case r_down:
18931 return movexy(px*diagrate, px*diagrate, kb, ign_sv, shove, earlyret);
18932 case l_up:
18933 return movexy(-px*diagrate, -px*diagrate, kb, ign_sv, shove, earlyret);
18934 case l_down:
18935 return movexy(-px*diagrate, px*diagrate, kb, ign_sv, shove, earlyret);
18936 }
18937 return false;
18938 440764 }
18939 440764 bool HeroClass::can_moveDir(int dir, zfix px, bool kb, bool ign_sv, bool shove)
18940 {
18941
1/2
✓ Branch 0 taken 440764 times.
✗ Branch 1 not taken.
881528 return handle_movestate([&]()
18942 {
18943 440764 return moveDir(dir,px,kb,ign_sv,shove,true);
18944 });
18945 }
18946
18947
18948 391624 bool HeroClass::premove()
18949 {
18950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391624 times.
391624 if(lstunclock) return false;
18951
3/4
✓ Branch 0 taken 3217 times.
✓ Branch 1 taken 388407 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3217 times.
391624 if(is_conveyor_stunned) return (convey_forcex || convey_forcey);
18952 388407 int32_t xoff=x.getInt()&7;
18953 388407 int32_t yoff=y.getInt()&7;
18954
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 388407 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
388407 if(NO_GRIDLOCK)
18955 {
18956 388407 xoff = 0;
18957 388407 yoff = 0;
18958 388407 }
18959 388407 int32_t push=pushing;
18960 388407 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
18961 388407 int32_t flippers_id = current_item_id(itype_flippers);
18962 388407 itemdata const& itm = itemsbuf[flippers_id];
18963 388407 byte intbtn = byte(itm.misc3&0xFF);
18964 388407 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
18965 388407 bool eatdive = false;
18966
2/2
✓ Branch 0 taken 411 times.
✓ Branch 1 taken 387996 times.
388407 if(diveclk>0)
18967 {
18968
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 411 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
411 if (isSideViewHero() && get_qr(qr_SIDESWIM)) diveclk = 0;
18969 411 --diveclk;
18970
4/8
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 326 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 326 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
411 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && dive_pressed) //Cancellable Diving -V
18971 {
18972 diveclk = itemsbuf[flippers_id].misc2;
18973 eatdive = true;
18974 }
18975 411 }
18976
4/4
✓ Branch 0 taken 6251 times.
✓ Branch 1 taken 381745 times.
✓ Branch 2 taken 6240 times.
✓ Branch 3 taken 11 times.
387996 else if(action == swimming && dive_pressed)
18977 {
18978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
18979 11 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
18980
18981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(global_diving==screen_diving)
18982 {
18983
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
18984 11 eatdive = true;
18985 11 }
18986 11 }
18987
2/2
✓ Branch 0 taken 388396 times.
✓ Branch 1 taken 11 times.
388407 if(eatdive)
18988 11 getIntBtnInput(intbtn, true, true, false, false, false);
18989
18990
1/2
✓ Branch 0 taken 388407 times.
✗ Branch 1 not taken.
388407 if(action==rafting)
18991 {
18992 do_rafting();
18993
18994 if(action==rafting)
18995 {
18996 return false;
18997 }
18998
18999
19000 set_respawn_point();
19001 trySideviewLadder();
19002 }
19003
19004 388407 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
19005 388407 int32_t btnwpn = -1;
19006
19007 //&0xFFF removes the "bow & arrows" bitmask
19008 //The Quick Sword is allowed to interrupt attacks.
19009
4/4
✓ Branch 0 taken 377729 times.
✓ Branch 1 taken 10678 times.
✓ Branch 2 taken 256212 times.
✓ Branch 3 taken 121517 times.
388407 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
19010
7/8
✓ Branch 0 taken 354285 times.
✓ Branch 1 taken 34122 times.
✓ Branch 2 taken 354220 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 5547 times.
✓ Branch 5 taken 28640 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 34187 times.
388407 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
19011 {
19012
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 354046 times.
354220 if(DrunkrBbtn())
19013 {
19014 174 btnwpn=getItemFamily(itemsbuf,Bwpn);
19015
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 dowpn = NEG_OR_MASK(Bwpn,0xFFF);
19016 174 directWpn = directItemB;
19017 174 }
19018
2/2
✓ Branch 0 taken 2097 times.
✓ Branch 1 taken 351949 times.
354046 else if(DrunkrAbtn())
19019 {
19020 2097 btnwpn=getItemFamily(itemsbuf,Awpn);
19021
1/2
✓ Branch 0 taken 2097 times.
✗ Branch 1 not taken.
2097 dowpn = NEG_OR_MASK(Awpn,0xFFF);
19022 2097 directWpn = directItemA;
19023 2097 }
19024
3/4
✓ Branch 0 taken 351949 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351826 times.
✓ Branch 3 taken 123 times.
351949 else if(get_qr(qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
19025 {
19026 123 btnwpn=getItemFamily(itemsbuf,Xwpn);
19027
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 dowpn = NEG_OR_MASK(Xwpn,0xFFF);
19028 123 directWpn = directItemX;
19029 123 }
19030
3/4
✓ Branch 0 taken 351826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351713 times.
✓ Branch 3 taken 113 times.
351826 else if(get_qr(qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
19031 {
19032 113 btnwpn=getItemFamily(itemsbuf,Ywpn);
19033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 dowpn = NEG_OR_MASK(Ywpn,0xFFF);
19034 113 directWpn = directItemY;
19035 113 }
19036
19037
1/2
✓ Branch 0 taken 354220 times.
✗ Branch 1 not taken.
354220 if(directWpn >= MAXITEMS) directWpn = -1;
19038
19039 // The Quick Sword only allows repeated sword or wand swings.
19040
3/8
✓ Branch 0 taken 354220 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 354220 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 354220 times.
354220 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
19041 btnwpn=-1;
19042 354220 }
19043
19044
2/2
✓ Branch 0 taken 132197 times.
✓ Branch 1 taken 256210 times.
388407 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
19045
10/12
✓ Branch 0 taken 373805 times.
✓ Branch 1 taken 14602 times.
✓ Branch 2 taken 371156 times.
✓ Branch 3 taken 2649 times.
✓ Branch 4 taken 244736 times.
✓ Branch 5 taken 126420 times.
✓ Branch 6 taken 244736 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2097 times.
✓ Branch 9 taken 242639 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2097 times.
388407 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
19046 {
19047
1/2
✓ Branch 0 taken 2097 times.
✗ Branch 1 not taken.
2097 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
19048
2/6
✓ Branch 0 taken 2097 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2097 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2097 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
19049 {
19050
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2097 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
19051 {
19052 paymagiccost(attackid,true);
19053 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
19054 }
19055 2097 SetAttack();
19056 2097 attack=wSword;
19057
19058 2097 attackclk=0;
19059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2097 times.
2097 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
19060
19061
2/10
✓ Branch 0 taken 2097 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2097 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2097 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
19062 {
19063 if(!checkmagiccost(dowpn))
19064 {
19065 item_error();
19066 }
19067 else
19068 {
19069 //clear the item script stack for a new script
19070 int i = dowpn;
19071 FFCore.reset_script_engine_data(ScriptType::Item, i);
19072 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
19073 did_scripta=true;
19074 }
19075 }
19076 2097 }
19077 else
19078 {
19079 item_error();
19080 }
19081 2097 }
19082 else
19083 {
19084 386310 did_scripta=false;
19085 }
19086
19087
6/10
✓ Branch 0 taken 381745 times.
✓ Branch 1 taken 6662 times.
✓ Branch 2 taken 381745 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 381745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 381745 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 381745 times.
388407 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
19088 {
19089
3/4
✓ Branch 0 taken 67380 times.
✓ Branch 1 taken 314365 times.
✓ Branch 2 taken 67380 times.
✗ Branch 3 not taken.
381745 if(DrunkUp() && canSideviewLadder())
19090 {
19091 setOnSideviewLadder(true);
19092 }
19093
3/4
✓ Branch 0 taken 71299 times.
✓ Branch 1 taken 310446 times.
✓ Branch 2 taken 71299 times.
✗ Branch 3 not taken.
381745 else if(DrunkDown() && canSideviewLadder(true))
19094 {
19095 y+=1;
19096 setOnSideviewLadder(true);
19097 }
19098 381745 }
19099
19100 388407 int32_t wx=x;
19101 388407 int32_t wy=y;
19102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388407 times.
388407 if(conv_forcedir > -1) dir = conv_forcedir;
19103
3/6
✓ Branch 0 taken 282848 times.
✓ Branch 1 taken 105559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 388407 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
388407 else if((action==none || action==walking) && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
19104 {
19105 if((xoff==0)||diagonalMovement)
19106 {
19107 if(DrunkUp()) dir=up;
19108 if(DrunkDown()) dir=down;
19109 }
19110
19111 if((yoff==0)||diagonalMovement)
19112 {
19113 if(DrunkLeft()) dir=left;
19114 if(DrunkRight()) dir=right;
19115 }
19116 }
19117
19118
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 78067 times.
✓ Branch 2 taken 85319 times.
✓ Branch 3 taken 113642 times.
✓ Branch 4 taken 111379 times.
388407 switch(dir)
19119 {
19120 case up:
19121 78067 wy-=16;
19122 78067 break;
19123
19124 case down:
19125 85319 wy+=16;
19126 85319 break;
19127
19128 case left:
19129 113642 wx-=16;
19130 113642 break;
19131
19132 case right:
19133 111379 wx+=16;
19134 111379 break;
19135 }
19136
19137 388407 do_lens();
19138
19139 388407 bool no_jinx = true;
19140
6/8
✓ Branch 0 taken 373805 times.
✓ Branch 1 taken 14602 times.
✓ Branch 2 taken 406 times.
✓ Branch 3 taken 373399 times.
✓ Branch 4 taken 406 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 406 times.
388407 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
19141 {
19142 406 bool paidmagic = false;
19143
1/2
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
406 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
19144
6/10
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 347 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 59 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 59 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 59 times.
406 if(!liftonly && btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
19145 {
19146
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
19147 59 no_jinx = checkitem_jinx(attackid);
19148
3/8
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
59 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
19149 {
19150
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
19151 paymagiccost(attackid,true);
19152 misc_internal_hero_flags |= LF_PAID_WAND_COST;
19153 }
19154 59 SetAttack();
19155 59 attack=wWand;
19156 59 attackclk=0;
19157 59 }
19158 else
19159 {
19160 item_error();
19161 }
19162 59 }
19163
2/8
✓ Branch 0 taken 347 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 347 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
347 else if(!liftonly && (btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
19164 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
19165 {
19166 no_jinx = checkitem_jinx(dowpn);
19167 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
19168 {
19169 item_error();
19170 }
19171 else
19172 {
19173 paymagiccost(dowpn);
19174 paidmagic = true;
19175 SetAttack();
19176 attack=wHammer;
19177 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
19178 attackclk=0;
19179 }
19180 }
19181
5/8
✓ Branch 0 taken 347 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 47 times.
394 else if(!liftonly && (btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
19182
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
47 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
19183 {
19184 //checkbunny handled where magic cost is paid
19185
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
19186 47 no_jinx = checkitem_jinx(attackid);
19187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(no_jinx)
19188 {
19189 47 SetAttack();
19190 47 attack=wFire;
19191 47 attackclk=0;
19192 47 }
19193 47 }
19194
2/8
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 300 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
300 else if(!liftonly && (btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
19195 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
19196 {
19197 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
19198 no_jinx = checkitem_jinx(attackid);
19199 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
19200 {
19201 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
19202 paymagiccost(attackid,true);
19203 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
19204 }
19205 SetAttack();
19206 attack=wCByrna;
19207 attackclk=0;
19208 }
19209 else
19210 {
19211 item_error();
19212 }
19213 }
19214
5/8
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 294 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
306 else if(!liftonly && (btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
19215
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
6 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
19216 {
19217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
19218 6 no_jinx = checkitem_jinx(attackid);
19219
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
6 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
19220 {
19221 6 paymagiccost(attackid);
19222 6 SetAttack();
19223 6 attack = wBugNet;
19224 6 attackclk = 0;
19225 6 sfx(itemsbuf[attackid].usesound);
19226 6 }
19227 else
19228 {
19229 item_error();
19230 }
19231 6 }
19232 else
19233 {
19234
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
19235 294 no_jinx = checkitem_jinx(itmid);
19236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 if(no_jinx)
19237 {
19238 294 paidmagic = startwpn(itmid);
19239
19240
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 if(paidmagic)
19241 {
19242
5/10
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 294 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 294 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 294 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 294 times.
294 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
19243 {
19244 ;
19245 }
19246 else
19247 {
19248 294 SetAttack();
19249 294 attackclk=0;
19250 294 attack=none;
19251
19252
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 172 times.
294 if(btnwpn==itype_brang)
19253 {
19254 122 attack=wBrang;
19255 122 }
19256 }
19257 294 }
19258 else
19259 {
19260 // Weapon not started: directWpn should be reset to prev. value.
19261 directWpn = olddirectwpn;
19262 }
19263 294 }
19264 }
19265
19266
3/12
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 406 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 406 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
406 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
19267 {
19268 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
19269 {
19270 item_error();
19271 }
19272 else
19273 {
19274 // Only charge for magic if item's magic cost wasn't already charged
19275 // for the item's main use.
19276 if(!paidmagic && attack!=wWand)
19277 paymagiccost(dowpn);
19278 //clear the item script stack for a new script
19279 int i = dowpn;
19280 FFCore.reset_script_engine_data(ScriptType::Item, i);
19281 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
19282 did_scriptb=true;
19283 }
19284 }
19285
19286
6/12
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 406 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 406 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 406 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 406 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 406 times.
406 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
19287 {
19288 return false;
19289 }
19290
1/2
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
406 if(!no_jinx)
19291 did_scriptb = false;
19292 406 }
19293 else
19294 {
19295 388001 did_scriptb=false;
19296 }
19297
19298
5/6
✓ Branch 0 taken 354285 times.
✓ Branch 1 taken 34122 times.
✓ Branch 2 taken 351717 times.
✓ Branch 3 taken 2568 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 351717 times.
388407 if(attackclk || action==attacking || action==sideswimattacking)
19299 {
19300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36690 times.
36690 if(conv_forcedir > -1) dir = conv_forcedir;
19301
4/8
✓ Branch 0 taken 2568 times.
✓ Branch 1 taken 34122 times.
✓ Branch 2 taken 2568 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2568 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
36690 else if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
19302 {
19303 if((xoff==0)||diagonalMovement)
19304 {
19305 if(DrunkUp()) dir=up;
19306 if(DrunkDown()) dir=down;
19307 }
19308
19309 if((yoff==0)||diagonalMovement)
19310 {
19311 if(DrunkLeft()) dir=left;
19312 if(DrunkRight()) dir=right;
19313 }
19314 }
19315
19316 36690 bool attacked = doattack();
19317
19318 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
19319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36690 times.
36690 if(conv_forcedir > -1) dir = conv_forcedir;
19320
8/12
✓ Branch 0 taken 36690 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26520 times.
✓ Branch 3 taken 10170 times.
✓ Branch 4 taken 4890 times.
✓ Branch 5 taken 21630 times.
✓ Branch 6 taken 4890 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4890 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4890 times.
36690 else if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
19321 {
19322
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4890 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4890 if((xoff==0)||diagonalMovement)
19323 {
19324
2/2
✓ Branch 0 taken 4645 times.
✓ Branch 1 taken 245 times.
4890 if(DrunkUp()) dir=up;
19325
19326
2/2
✓ Branch 0 taken 4379 times.
✓ Branch 1 taken 511 times.
4890 if(DrunkDown()) dir=down;
19327 4890 }
19328
19329
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4890 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4890 if((yoff==0)||diagonalMovement)
19330 {
19331
2/2
✓ Branch 0 taken 4397 times.
✓ Branch 1 taken 493 times.
4890 if(DrunkLeft()) dir=left;
19332
19333
2/2
✓ Branch 0 taken 4339 times.
✓ Branch 1 taken 551 times.
4890 if(DrunkRight()) dir=right;
19334 4890 }
19335 4890 }
19336
19337
6/10
✓ Branch 0 taken 34223 times.
✓ Branch 1 taken 2467 times.
✓ Branch 2 taken 34223 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34223 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34223 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 34223 times.
36690 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
19338 {
19339 34223 return false;
19340 }
19341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2467 times.
2467 else if(!attacked)
19342 {
19343 // Spin attack - change direction
19344
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2467 if(spins>1 && attack != wHammer)
19345 {
19346 spins--;
19347
19348 if(spins%5==0)
19349 {
19350 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
19351 sfx(itemsbuf[id].usesound,pan(x.getInt()));
19352 }
19353 attackclk=1;
19354
19355 switch(dir)
19356 {
19357 case up:
19358 dir=left;
19359 break;
19360
19361 case right:
19362 dir=up;
19363 break;
19364
19365 case down:
19366 dir=right;
19367 break;
19368
19369 case left:
19370 dir=down;
19371 break;
19372 }
19373
19374 return false;
19375 }
19376 else
19377 {
19378 2467 spins=0;
19379 }
19380
19381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2467 times.
2467 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
19382 2467 else {action=none; FFCore.setHeroAction(none);}
19383 2467 attackclk=0;
19384 2467 charging=0;
19385 2467 }
19386 2467 }
19387 354184 return true;
19388 391624 }
19389 446704 void HeroClass::movehero()
19390 {
19391 446704 bool earlyret = false;
19392
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 446704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
446704 bool nohorz = (isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam);
19393
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 446704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
446704 bool novert = (isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam);
19394 446704 zfix dx, dy;
19395 446704 auto push=pushing;
19396 446704 pushing=0;
19397
19398
2/2
✓ Branch 0 taken 92520 times.
✓ Branch 1 taken 354184 times.
446704 if(!is_conveyor_stunned) //these do not apply to conveyor auto-walk
19399 {
19400
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 354121 times.
354184 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
19401 63 return;
19402
19403
2/2
✓ Branch 0 taken 113350 times.
✓ Branch 1 taken 240771 times.
354121 if(action==walking) //still walking
19404 {
19405
9/10
✓ Branch 0 taken 176973 times.
✓ Branch 1 taken 63798 times.
✓ Branch 2 taken 111511 times.
✓ Branch 3 taken 65462 times.
✓ Branch 4 taken 58564 times.
✓ Branch 5 taken 52947 times.
✓ Branch 6 taken 3076 times.
✓ Branch 7 taken 55488 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3076 times.
240771 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
19406 {
19407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3076 times.
3076 if(attackclk>0) SetAttack();
19408 3076 else {action = none; FFCore.setHeroAction(none);}
19409 3076 hero_count=-1;
19410 3076 earlyret = true;
19411 3076 goto newmove_slide;
19412 }
19413
19414 237695 autostep=false;
19415 237695 } // endif (action==walking)
19416
19417
13/24
✓ Branch 0 taken 344383 times.
✓ Branch 1 taken 6662 times.
✓ Branch 2 taken 344383 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 344383 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 344383 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 344383 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 344383 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 344383 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 344383 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 344383 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 344383 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 344383 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 344383 times.
351045 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
19418 {
19419 344383 action=none; FFCore.setHeroAction(none);
19420 344383 }
19421 351045 }
19422
19423
2/2
✓ Branch 0 taken 92520 times.
✓ Branch 1 taken 351045 times.
979650 if(is_conveyor_stunned)
19424 {
19425 92520 dx = convey_forcex;
19426 92520 dy = convey_forcey;
19427 92520 convey_forcex = 0;
19428 92520 convey_forcey = 0;
19429
1/2
✓ Branch 0 taken 92520 times.
✗ Branch 1 not taken.
92520 if(action != walking)
19430 {
19431 action = walking; FFCore.setHeroAction(walking);
19432 }
19433 92520 }
19434
1/2
✓ Branch 0 taken 351045 times.
✗ Branch 1 not taken.
351045 else if(diagonalMovement)
19435 {
19436
5/5
✓ Branch 0 taken 100590 times.
✓ Branch 1 taken 48175 times.
✓ Branch 2 taken 52157 times.
✓ Branch 3 taken 72009 times.
✓ Branch 4 taken 78114 times.
351045 switch(holddir)
19437 {
19438 case up:
19439
2/2
✓ Branch 0 taken 46260 times.
✓ Branch 1 taken 1915 times.
48175 if(!Up())
19440 {
19441 1915 holddir=-1;
19442 1915 }
19443
19444 48175 break;
19445
19446 case down:
19447
2/2
✓ Branch 0 taken 50196 times.
✓ Branch 1 taken 1961 times.
52157 if(!Down())
19448 {
19449 1961 holddir=-1;
19450 1961 }
19451
19452 52157 break;
19453
19454 case left:
19455
2/2
✓ Branch 0 taken 69690 times.
✓ Branch 1 taken 2319 times.
72009 if(!Left())
19456 {
19457 2319 holddir=-1;
19458 2319 }
19459
19460 72009 break;
19461
19462 case right:
19463
2/2
✓ Branch 0 taken 75770 times.
✓ Branch 1 taken 2344 times.
78114 if(!Right())
19464 {
19465 2344 holddir=-1;
19466 2344 }
19467
19468 78114 break;
19469
19470 default:
19471 100590 break;
19472 } //end switch
19473
19474
6/6
✓ Branch 0 taken 67280 times.
✓ Branch 1 taken 283765 times.
✓ Branch 2 taken 65360 times.
✓ Branch 3 taken 1920 times.
✓ Branch 4 taken 46260 times.
✓ Branch 5 taken 48180 times.
351045 if(DrunkUp()&&(holddir==-1||holddir==up)&&!novert)
19475 {
19476
4/10
✓ Branch 0 taken 48180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48180 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48180 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 48180 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
48180 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
19477 {
19478 48180 dir=up;
19479 48180 }
19480 48180 holddir=up;
19481
19482
5/6
✓ Branch 0 taken 7837 times.
✓ Branch 1 taken 40343 times.
✓ Branch 2 taken 7829 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7829 times.
48180 if(DrunkRight()&&shiftdir!=left&&!nohorz)
19483 {
19484 7829 shiftdir=right;
19485
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7829 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
19486
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7829 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
19487 7829 }
19488
5/6
✓ Branch 0 taken 6059 times.
✓ Branch 1 taken 34292 times.
✓ Branch 2 taken 6052 times.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6052 times.
40351 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
19489 {
19490 6052 shiftdir=left;
19491
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6052 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6052 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
19492
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6052 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6052 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
19493 6052 }
19494 else
19495 {
19496 34299 shiftdir=-1;
19497 }
19498 48180 }
19499
6/6
✓ Branch 0 taken 68782 times.
✓ Branch 1 taken 326603 times.
✓ Branch 2 taken 66817 times.
✓ Branch 3 taken 1965 times.
✓ Branch 4 taken 16621 times.
✓ Branch 5 taken 52161 times.
395385 else if(DrunkDown()&&(holddir==-1||holddir==down)&&!novert)
19500 {
19501
4/10
✓ Branch 0 taken 52161 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52161 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52161 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 52161 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
52161 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
19502 {
19503 52161 dir=down;
19504 52161 }
19505 52161 holddir=down;
19506
19507
5/6
✓ Branch 0 taken 6593 times.
✓ Branch 1 taken 45568 times.
✓ Branch 2 taken 6578 times.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6578 times.
52161 if(DrunkRight()&&shiftdir!=left&&!nohorz)
19508 {
19509 6578 shiftdir=right;
19510
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6578 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6578 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
19511
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6578 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6578 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
19512 6578 }
19513
5/6
✓ Branch 0 taken 8441 times.
✓ Branch 1 taken 37142 times.
✓ Branch 2 taken 8430 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8430 times.
45583 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
19514 {
19515 8430 shiftdir=left;
19516
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8430 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
19517
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8430 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
19518 8430 }
19519 else
19520 {
19521 37153 shiftdir=-1;
19522 }
19523 52161 }
19524
6/6
✓ Branch 0 taken 72151 times.
✓ Branch 1 taken 271073 times.
✓ Branch 2 taken 69829 times.
✓ Branch 3 taken 2322 times.
✓ Branch 4 taken 139 times.
✓ Branch 5 taken 72012 times.
343224 else if(DrunkLeft()&&(holddir==-1||holddir==left)&&!nohorz)
19525 {
19526
3/6
✓ Branch 0 taken 72012 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72012 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 72012 times.
72012 if(charging==0 && spins==0 && action != sideswimattacking)
19527 {
19528 72012 dir=left;
19529 72012 }
19530 72012 sideswimdir = left;
19531 72012 holddir=left;
19532
19533
4/6
✓ Branch 0 taken 8343 times.
✓ Branch 1 taken 63669 times.
✓ Branch 2 taken 8343 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8343 times.
72012 if(DrunkUp()&&shiftdir!=down&&!novert)
19534 {
19535 8343 shiftdir=up;
19536 8343 }
19537
5/6
✓ Branch 0 taken 7856 times.
✓ Branch 1 taken 55813 times.
✓ Branch 2 taken 7855 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7855 times.
63669 else if(DrunkDown()&&shiftdir!=up&&!novert)
19538 {
19539 7855 shiftdir=down;
19540 7855 }
19541 else
19542 {
19543 55814 shiftdir=-1;
19544 }
19545 72012 }
19546
5/6
✓ Branch 0 taken 78114 times.
✓ Branch 1 taken 193098 times.
✓ Branch 2 taken 75770 times.
✓ Branch 3 taken 2344 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 78114 times.
271212 else if(DrunkRight()&&(holddir==-1||holddir==right)&&!nohorz)
19547 {
19548
3/6
✓ Branch 0 taken 78114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 78114 times.
78114 if(charging==0 && spins==0 && action != sideswimattacking)
19549 {
19550 78114 dir=right;
19551 78114 }
19552 78114 sideswimdir = right;
19553 78114 holddir=right;
19554
19555
4/6
✓ Branch 0 taken 10757 times.
✓ Branch 1 taken 67357 times.
✓ Branch 2 taken 10757 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10757 times.
78114 if(DrunkUp()&&shiftdir!=down&&!novert)
19556 {
19557 10757 shiftdir=up;
19558 10757 }
19559
5/6
✓ Branch 0 taken 8763 times.
✓ Branch 1 taken 58594 times.
✓ Branch 2 taken 8761 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8761 times.
67357 else if(DrunkDown()&&shiftdir!=up&&!novert)
19560 {
19561 8761 shiftdir=down;
19562 8761 }
19563 else
19564 {
19565 58596 shiftdir=-1;
19566 }
19567 78114 }
19568 else
19569 {
19570 193098 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
19571 193098 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
19572 193098 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
19573 193098 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
19574 193098 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
19575
19576
9/12
✓ Branch 0 taken 28585 times.
✓ Branch 1 taken 164513 times.
✓ Branch 2 taken 28528 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 185 times.
✓ Branch 5 taken 28343 times.
✓ Branch 6 taken 28528 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28528 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 28528 times.
✗ Branch 11 not taken.
193098 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
19577 {
19578
8/12
✓ Branch 0 taken 579 times.
✓ Branch 1 taken 27949 times.
✓ Branch 2 taken 311 times.
✓ Branch 3 taken 268 times.
✓ Branch 4 taken 294 times.
✓ Branch 5 taken 17 times.
✓ Branch 6 taken 294 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 294 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
28528 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
19579 {
19580 //action=swimming;
19581
2/12
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 294 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
294 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
19582 {
19583 hopclk = 0xFF;
19584 }
19585 294 }
19586 28528 }
19587 193098 earlyret = true;
19588 }
19589
2/2
✓ Branch 0 taken 193098 times.
✓ Branch 1 taken 250467 times.
443565 if(earlyret)
19590 193098 dx = dy = 0;
19591 250467 else get_move(holddir,dx,dy,dir);
19592 443565 }
19593 else //4-way
19594 {
19595 shiftdir = -1;
19596 holddir = -1;
19597 if(!novert && DrunkUp())
19598 {
19599 holddir = dir = up;
19600 }
19601 else if(!novert && DrunkDown())
19602 {
19603 holddir = dir = down;
19604 }
19605 else if(!nohorz && DrunkLeft())
19606 {
19607 holddir = dir = left;
19608 }
19609 else if(!nohorz && DrunkRight())
19610 {
19611 holddir = dir = right;
19612 }
19613 get_move(holddir,dx,dy,dir);
19614 }
19615
19616 newmove_slide:
19617
1/2
✓ Branch 0 taken 354121 times.
✗ Branch 1 not taken.
354121 if(conv_forcedir > -1)
19618 dir = conv_forcedir;
19619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354121 times.
354121 if(!is_conveyor_stunned)
19620 {
19621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354121 times.
354121 bool is_inair = (z > 0 || fakez > 0);
19622 354121 auto ic = ice_combo;
19623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354121 times.
354121 if(!is_inair) //maintain momentum when jumping
19624 {
19625 354121 const int sens = 2;
19626 354121 auto ty = y+(bigHitbox?0:8);
19627 354121 int xs[] = {x+7, x+sens, x+sens, x+15-sens, x+15-sens};
19628 354121 int ys[] = {y+(bigHitbox?8:12), ty+sens, y+15-sens, ty+sens, y+15-sens};
19629 354121 bool found = false;
19630
2/2
✓ Branch 0 taken 354121 times.
✓ Branch 1 taken 1770605 times.
2124726 for(int q = 0; q < 5; ++q)
19631 {
19632 1770605 auto ice = get_icy(xs[q], ys[q], ICY_PLAYER);
19633
1/2
✓ Branch 0 taken 1770605 times.
✗ Branch 1 not taken.
1770605 if(ice)
19634 {
19635 ic = ice_combo = ice;
19636 found = true;
19637 break;
19638 }
19639 1770605 }
19640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354121 times.
354121 if(!found)
19641 354121 ic = ice_combo = 0;
19642 354121 }
19643
1/2
✓ Branch 0 taken 354121 times.
✗ Branch 1 not taken.
354121 if(script_ice_combo)
19644 {
19645 if((unsigned(script_ice_combo) < MAXCOMBOS) && check_icy(combobuf[script_ice_combo], ICY_PLAYER))
19646 ic = script_ice_combo;
19647 else ic = 0;
19648 }
19649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354121 times.
354121 if(ic)
19650 {
19651 handle_slide(combobuf[ic], dx, dy);
19652 earlyret = false;
19653 }
19654 354121 else clear_ice();
19655 354121 }
19656 else clear_ice();
19657
2/2
✓ Branch 0 taken 250467 times.
✓ Branch 1 taken 103654 times.
354121 if(earlyret)
19658 103654 return;
19659
19660
2/2
✓ Branch 0 taken 212598 times.
✓ Branch 1 taken 37869 times.
250467 if(!new_engine_move(dx,dy))
19661 37869 pushing = push+1;
19662 354184 }
19663
19664 407077 void HeroClass::get_move(int movedir, zfix& dx, zfix& dy, int32_t& facedir)
19665 {
19666 407077 dx = 0; dy = 0;
19667
6/8
✓ Branch 0 taken 250467 times.
✓ Branch 1 taken 156610 times.
✓ Branch 2 taken 250467 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250467 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 156610 times.
✓ Branch 7 taken 407077 times.
407077 if(inlikelike || lstunclock > 0 || is_conveyor_stunned || movedir < 0)
19668 313220 return;
19669
19670 407077 zfix base_movepix(zfix(steprate) / 100);
19671 407077 zfix movepix(base_movepix);
19672 407077 zfix up_step(zfix(game->get_sideswim_up()) / 100);
19673 407077 zfix left_step(zfix(game->get_sideswim_side()) / 100);
19674 407077 zfix right_step(zfix(game->get_sideswim_side()) / 100);
19675 407077 zfix down_step(zfix(game->get_sideswim_down()) / 100);
19676 407077 std::vector<zfix*> steps;
19677
2/2
✓ Branch 0 taken 250467 times.
✓ Branch 1 taken 156610 times.
407077 steps.push_back(&movepix);
19678
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 steps.push_back(&up_step);
19679
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 steps.push_back(&left_step);
19680
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 steps.push_back(&right_step);
19681
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 steps.push_back(&down_step);
19682
19683
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 mod_steps(steps);
19684
19685
2/4
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250467 times.
✗ Branch 3 not taken.
250467 up_step = -up_step;
19686
2/4
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250467 times.
✗ Branch 3 not taken.
250467 left_step = -left_step;
19687
19688
19689
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 zfix step(movepix);
19690
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 zfix step_diag(movepix);
19691
19692
19693
1/2
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
250467 if (diagonalMovement)
19694 {
19695 //zprint2("Player's X is %d, Y is %d\n", x, y);
19696
6/6
✓ Branch 0 taken 202287 times.
✓ Branch 1 taken 48180 times.
✓ Branch 2 taken 42009 times.
✓ Branch 3 taken 244296 times.
✓ Branch 4 taken 85859 times.
✓ Branch 5 taken 4330 times.
381493 if (((movedir == up || movedir == down) && (shiftdir == left || shiftdir == right)) ||
19697
4/4
✓ Branch 0 taken 149566 times.
✓ Branch 1 taken 94730 times.
✓ Branch 2 taken 36296 times.
✓ Branch 3 taken 185862 times.
244296 (movedir == left || movedir == right) && (shiftdir == up || shiftdir == down))
19698 {
19699
4/6
✓ Branch 0 taken 64605 times.
✓ Branch 1 taken 156610 times.
✓ Branch 2 taken 64605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64605 times.
✗ Branch 5 not taken.
221215 step = STEP_DIAGONAL(step);
19700
3/6
✓ Branch 0 taken 64605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64605 times.
✗ Branch 5 not taken.
64605 up_step = STEP_DIAGONAL(up_step);
19701
3/6
✓ Branch 0 taken 64605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64605 times.
✗ Branch 5 not taken.
64605 left_step = STEP_DIAGONAL(left_step);
19702
3/6
✓ Branch 0 taken 64605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64605 times.
✗ Branch 5 not taken.
64605 right_step = STEP_DIAGONAL(right_step);
19703
3/6
✓ Branch 0 taken 64605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64605 times.
✗ Branch 5 not taken.
64605 down_step = STEP_DIAGONAL(down_step);
19704 64605 }
19705
4/5
✓ Branch 0 taken 48180 times.
✓ Branch 1 taken 52161 times.
✓ Branch 2 taken 72012 times.
✓ Branch 3 taken 78114 times.
✗ Branch 4 not taken.
250467 switch (movedir)
19706 {
19707 case up:
19708
3/3
✓ Branch 0 taken 6052 times.
✓ Branch 1 taken 7829 times.
✓ Branch 2 taken 34299 times.
48180 switch (shiftdir)
19709 {
19710 case left:
19711
4/10
✓ Branch 0 taken 6052 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6052 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6052 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6052 times.
✗ Branch 9 not taken.
6052 dx = IsSideSwim() ? left_step : -step;
19712 6052 break;
19713 case right:
19714
3/6
✓ Branch 0 taken 7829 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7829 times.
✓ Branch 4 taken 7829 times.
✗ Branch 5 not taken.
7829 dx = IsSideSwim() ? right_step : step;
19715 7829 break;
19716 }
19717
2/4
✓ Branch 0 taken 48180 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 48180 times.
48180 if (IsSideSwim())
19718 {
19719 dy = up_step;
19720 }
19721
2/4
✓ Branch 0 taken 48180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48180 times.
✗ Branch 3 not taken.
48180 else dy = -step;
19722 48180 break;
19723 case down:
19724
3/3
✓ Branch 0 taken 8430 times.
✓ Branch 1 taken 6578 times.
✓ Branch 2 taken 37153 times.
52161 switch (shiftdir)
19725 {
19726 case left:
19727
2/4
✓ Branch 0 taken 8430 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8430 times.
✗ Branch 3 not taken.
8430 dx = -step;
19728
2/6
✓ Branch 0 taken 8430 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8430 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8430 if (IsSideSwim()) dx = left_step;
19729 8430 break;
19730 case right:
19731
1/2
✓ Branch 0 taken 6578 times.
✗ Branch 1 not taken.
6578 dx = step;
19732
2/6
✓ Branch 0 taken 6578 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6578 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6578 if (IsSideSwim()) dx = right_step;
19733 6578 break;
19734 }
19735
3/6
✓ Branch 0 taken 52161 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 52161 times.
✓ Branch 4 taken 52161 times.
✗ Branch 5 not taken.
52161 dy = IsSideSwim() ? down_step : step;
19736 52161 break;
19737 case left:
19738
3/3
✓ Branch 0 taken 8343 times.
✓ Branch 1 taken 7855 times.
✓ Branch 2 taken 55814 times.
72012 switch (shiftdir)
19739 {
19740 case up:
19741
2/4
✓ Branch 0 taken 8343 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8343 times.
8343 if (IsSideSwim())
19742 {
19743 dy = up_step;
19744 }
19745
2/4
✓ Branch 0 taken 8343 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8343 times.
✗ Branch 3 not taken.
8343 else dy = -step;
19746 8343 break;
19747 case down:
19748
1/2
✓ Branch 0 taken 7855 times.
✗ Branch 1 not taken.
7855 dy = step;
19749
2/6
✓ Branch 0 taken 7855 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7855 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7855 if (IsSideSwim()) dy = down_step;
19750 7855 break;
19751 }
19752
4/10
✓ Branch 0 taken 72012 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72012 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 72012 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 72012 times.
✗ Branch 9 not taken.
72012 dx = IsSideSwim() ? left_step : -step;
19753 72012 break;
19754 case right:
19755
3/3
✓ Branch 0 taken 10757 times.
✓ Branch 1 taken 8761 times.
✓ Branch 2 taken 58596 times.
78114 switch (shiftdir)
19756 {
19757 case up:
19758
4/8
✓ Branch 0 taken 10757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10757 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10757 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10757 times.
✗ Branch 7 not taken.
10757 if (!IsSideSwim()) dy = -step;
19759
2/4
✓ Branch 0 taken 10757 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10757 times.
10757 if (IsSideSwim())
19760 {
19761 dy = up_step;
19762 }
19763 10757 break;
19764 case down:
19765
1/2
✓ Branch 0 taken 8761 times.
✗ Branch 1 not taken.
8761 dy = step;
19766
2/6
✓ Branch 0 taken 8761 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8761 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8761 if (IsSideSwim()) dy = down_step;
19767 8761 break;
19768 }
19769
3/6
✓ Branch 0 taken 78114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78114 times.
✓ Branch 4 taken 78114 times.
✗ Branch 5 not taken.
78114 dx = IsSideSwim() ? right_step : step;
19770 78114 break;
19771 };
19772 250467 }
19773 else
19774 {
19775 switch (movedir)
19776 {
19777 case up:
19778 dy = IsSideSwim() ? up_step : -step;
19779 break;
19780 case down:
19781 dy = IsSideSwim() ? down_step : step;
19782 break;
19783 case left:
19784 dx = IsSideSwim() ? left_step : -step;
19785 break;
19786 case right:
19787 dx = IsSideSwim() ? right_step : step;
19788 break;
19789 };
19790 }
19791
19792
2/8
✓ Branch 0 taken 250467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 250467 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
250467 if (isSideViewHero() && slopeid)
19793 {
19794 dy += (dx*slopeid);
19795 }
19796
19797
6/18
✗ Branch 0 not taken.
✓ Branch 1 taken 250467 times.
✓ Branch 2 taken 250467 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250467 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 250467 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 250467 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 250467 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
250467 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (movedir == up || movedir == down))) //!DIRECTION SET
19798 {
19799 250467 facedir = movedir;
19800 250467 }
19801 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (movedir == up || movedir == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
19802 {
19803 facedir = shiftdir;
19804 }
19805 563687 }
19806
19807 250467 bool HeroClass::new_engine_move(zfix dx, zfix dy) //no collision check
19808 {
19809
3/4
✓ Branch 0 taken 71452 times.
✓ Branch 1 taken 179015 times.
✓ Branch 2 taken 71452 times.
✗ Branch 3 not taken.
250467 if(!dx && !dy) return true;
19810
5/8
✓ Branch 0 taken 244177 times.
✓ Branch 1 taken 6290 times.
✓ Branch 2 taken 244177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 244177 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 244177 times.
250467 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
19811 {
19812 244177 herostep();
19813
19814 //ack... don't walk if in midair! -DD
19815
5/14
✓ Branch 0 taken 244177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 244177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 244177 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 244177 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 244177 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
244177 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(this) && !getOnSideviewLadder()))
19816 {
19817 244177 action=walking; FFCore.setHeroAction(walking);
19818 244177 }
19819
19820
2/2
✓ Branch 0 taken 231372 times.
✓ Branch 1 taken 12805 times.
244177 if(++hero_count > (16*hero_animation_speed))
19821 12805 hero_count=0;
19822 244177 }
19823
2/2
✓ Branch 0 taken 3148 times.
✓ Branch 1 taken 3142 times.
6290 else if(!(frame & 1))
19824 {
19825 3142 herostep();
19826 3142 }
19827
19828 250467 bool ret = true;
19829
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
250467 if(charging==0 || attack!=wHammer)
19830 {
19831 250467 ret = movexy(dx,dy,false,false,true);
19832 250467 }
19833 250467 return ret;
19834 250467 }
19835
19836 7405584 void HeroClass::moveOld(int32_t d2)
19837 {
19838 //al_trace("%s\n",d2==up?"up":d2==down?"down":d2==left?"left":d2==right?"right":"?");
19839 static bool totalskip = false;
19840
19841
3/6
✓ Branch 0 taken 7405584 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7405584 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7405584 times.
7405584 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
19842 return;
19843
19844 7405584 int32_t dx=0,dy=0;
19845 7405584 int32_t xstep=lsteps[x.getInt()&7];
19846 7405584 int32_t ystep=lsteps[y.getInt()&7];
19847 7405584 int32_t z3skip=0;
19848 7405584 int32_t z3diagskip=0;
19849
5/6
✓ Branch 0 taken 200742 times.
✓ Branch 1 taken 7204842 times.
✓ Branch 2 taken 200680 times.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
14610488 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || tmpscr->flags2&fAIRCOMBOS)) ||
19850
5/6
✓ Branch 0 taken 149353 times.
✓ Branch 1 taken 7055551 times.
✓ Branch 2 taken 81755 times.
✓ Branch 3 taken 67598 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 81755 times.
7204904 (isSideViewHero() && (on_sideview_solid_oldpos(this)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
19851
2/2
✓ Branch 0 taken 7379769 times.
✓ Branch 1 taken 25815 times.
7405584 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
19852 7405584 bool is_swimming = (action == swimming);
19853
19854 //slow walk combo, or charging, moves at 2/3 speed
19855 if(
19856
4/4
✓ Branch 0 taken 7304750 times.
✓ Branch 1 taken 100834 times.
✓ Branch 2 taken 201043 times.
✓ Branch 3 taken 7103707 times.
7506418 (!is_swimming && (slowcharging ^ slowcombo))||
19857
2/2
✓ Branch 0 taken 100834 times.
✓ Branch 1 taken 7103707 times.
7204541 (is_swimming && (zinit.hero_swim_speed>60))
19858 )
19859 {
19860 301877 totalskip = false;
19861
19862
2/2
✓ Branch 0 taken 49244 times.
✓ Branch 1 taken 252633 times.
301877 if(diagonalMovement)
19863 {
19864 49244 skipstep=(skipstep+1)%6;
19865
19866
2/2
✓ Branch 0 taken 25024 times.
✓ Branch 1 taken 24220 times.
49244 if(skipstep%2==0) z3skip=1;
19867 25024 else z3skip=0;
19868
19869
2/2
✓ Branch 0 taken 33205 times.
✓ Branch 1 taken 16039 times.
49244 if(skipstep%3==0) z3diagskip=1;
19870 33205 else z3diagskip=0;
19871 49244 }
19872 else
19873 {
19874
2/2
✓ Branch 0 taken 165339 times.
✓ Branch 1 taken 87294 times.
252633 if(d2<left)
19875 {
19876
2/2
✓ Branch 0 taken 99954 times.
✓ Branch 1 taken 65385 times.
165339 if(ystep>1)
19877 {
19878 65385 skipstep^=1;
19879 65385 ystep=skipstep;
19880 65385 }
19881 165339 }
19882 else
19883 {
19884
2/2
✓ Branch 0 taken 53050 times.
✓ Branch 1 taken 34244 times.
87294 if(xstep>1)
19885 {
19886 34244 skipstep^=1;
19887 34244 xstep=skipstep;
19888 34244 }
19889 }
19890 }
19891 301877 }
19892 // else if(is_swimming || (slowcharging && slowcombo))
19893 else if(
19894
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7103707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7103818 (is_swimming && (zinit.hero_swim_speed<60))||
19895
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 7103596 times.
7103707 (slowcharging && slowcombo)
19896 )
19897 {
19898 //swimming, or charging on a slow combo, moves at 1/2 speed
19899 111 totalskip = !totalskip;
19900
19901
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(diagonalMovement)
19902 {
19903 skipstep=0;
19904 }
19905 111 }
19906 else
19907 {
19908 7103596 totalskip = false;
19909
19910
2/2
✓ Branch 0 taken 5124021 times.
✓ Branch 1 taken 1979575 times.
7103596 if(diagonalMovement)
19911 {
19912 1979575 skipstep=0;
19913 1979575 }
19914 }
19915
19916
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 7405528 times.
7405584 if(!totalskip)
19917 {
19918
2/2
✓ Branch 0 taken 2028819 times.
✓ Branch 1 taken 5376709 times.
7405528 if(diagonalMovement)
19919 {
19920
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 438170 times.
✓ Branch 2 taken 371317 times.
✓ Branch 3 taken 638688 times.
✓ Branch 4 taken 580644 times.
2028819 switch(d2)
19921 {
19922 case up:
19923
2/2
✓ Branch 0 taken 45143 times.
✓ Branch 1 taken 393027 times.
438170 if(shiftdir==left)
19924 {
19925
2/2
✓ Branch 0 taken 35829 times.
✓ Branch 1 taken 9314 times.
45143 if(walkable)
19926 {
19927 35829 dy-=1-z3diagskip;
19928 35829 dx-=1-z3diagskip;
19929 35829 z3step=2;
19930 35829 }
19931 else
19932 {
19933 9314 dx-=1-z3diagskip;
19934 9314 z3step=2;
19935 }
19936 45143 }
19937
2/2
✓ Branch 0 taken 54038 times.
✓ Branch 1 taken 338989 times.
393027 else if(shiftdir==right)
19938 {
19939
2/2
✓ Branch 0 taken 43363 times.
✓ Branch 1 taken 10675 times.
54038 if(walkable)
19940 {
19941 43363 dy-=1-z3diagskip;
19942 43363 dx+=1-z3diagskip;
19943 43363 z3step=2;
19944 43363 }
19945 else
19946 {
19947 10675 dx+=1-z3diagskip;
19948 10675 z3step=2;
19949 }
19950 54038 }
19951 else
19952 {
19953
2/2
✓ Branch 0 taken 57914 times.
✓ Branch 1 taken 281075 times.
338989 if(walkable)
19954 {
19955 281075 dy-=z3step-z3skip;
19956 281075 z3step=(z3step%2)+1;
19957 281075 }
19958 }
19959
19960 438170 break;
19961
19962 case down:
19963
2/2
✓ Branch 0 taken 50598 times.
✓ Branch 1 taken 320719 times.
371317 if(shiftdir==left)
19964 {
19965
2/2
✓ Branch 0 taken 38349 times.
✓ Branch 1 taken 12249 times.
50598 if(walkable)
19966 {
19967 38349 dy+=1-z3diagskip;
19968 38349 dx-=1-z3diagskip;
19969 38349 z3step=2;
19970 38349 }
19971 else
19972 {
19973 12249 dx-=1-z3diagskip;
19974 12249 z3step=2;
19975 }
19976 50598 }
19977
2/2
✓ Branch 0 taken 51916 times.
✓ Branch 1 taken 268803 times.
320719 else if(shiftdir==right)
19978 {
19979
2/2
✓ Branch 0 taken 39647 times.
✓ Branch 1 taken 12269 times.
51916 if(walkable)
19980 {
19981 39647 dy+=1-z3diagskip;
19982 39647 dx+=1-z3diagskip;
19983 39647 z3step=2;
19984 39647 }
19985 else
19986 {
19987 12269 dx+=1-z3diagskip;
19988 12269 z3step=2;
19989 }
19990 51916 }
19991 else
19992 {
19993
2/2
✓ Branch 0 taken 44704 times.
✓ Branch 1 taken 224099 times.
268803 if(walkable)
19994 {
19995 224099 dy+=z3step-z3skip;
19996 224099 z3step=(z3step%2)+1;
19997 224099 }
19998 }
19999
20000 371317 break;
20001
20002 case right:
20003
2/2
✓ Branch 0 taken 569130 times.
✓ Branch 1 taken 69558 times.
638688 if(shiftdir==up)
20004 {
20005
2/2
✓ Branch 0 taken 57827 times.
✓ Branch 1 taken 11731 times.
69558 if(walkable)
20006 {
20007 57827 dy-=1-z3diagskip;
20008 57827 dx+=1-z3diagskip;
20009 57827 z3step=2;
20010 57827 }
20011 else
20012 {
20013 11731 dy-=1-z3diagskip;
20014 11731 z3step=2;
20015 }
20016 69558 }
20017
2/2
✓ Branch 0 taken 54221 times.
✓ Branch 1 taken 514909 times.
569130 else if(shiftdir==down)
20018 {
20019
2/2
✓ Branch 0 taken 44924 times.
✓ Branch 1 taken 9297 times.
54221 if(walkable)
20020 {
20021 44924 dy+=1-z3diagskip;
20022 44924 dx+=1-z3diagskip;
20023 44924 z3step=2;
20024 44924 }
20025 else
20026 {
20027 9297 dy+=1-z3diagskip;
20028 9297 z3step=2;
20029 }
20030 54221 }
20031 else
20032 {
20033
2/2
✓ Branch 0 taken 59832 times.
✓ Branch 1 taken 455077 times.
514909 if(walkable)
20034 {
20035 455077 dx+=z3step-z3skip;
20036 455077 z3step=(z3step%2)+1;
20037 455077 }
20038 }
20039
20040 638688 break;
20041
20042 case left:
20043
2/2
✓ Branch 0 taken 515198 times.
✓ Branch 1 taken 65446 times.
580644 if(shiftdir==up)
20044 {
20045
2/2
✓ Branch 0 taken 55497 times.
✓ Branch 1 taken 9949 times.
65446 if(walkable)
20046 {
20047 55497 dy-=1-z3diagskip;
20048 55497 dx-=1-z3diagskip;
20049 55497 z3step=2;
20050 55497 }
20051 else
20052 {
20053 9949 dy-=1-z3diagskip;
20054 9949 z3step=2;
20055 }
20056 65446 }
20057
2/2
✓ Branch 0 taken 50500 times.
✓ Branch 1 taken 464698 times.
515198 else if(shiftdir==down)
20058 {
20059
2/2
✓ Branch 0 taken 42563 times.
✓ Branch 1 taken 7937 times.
50500 if(walkable)
20060 {
20061 42563 dy+=1-z3diagskip;
20062 42563 dx-=1-z3diagskip;
20063 42563 z3step=2;
20064 42563 }
20065 else
20066 {
20067 7937 dy+=1-z3diagskip;
20068 7937 z3step=2;
20069 }
20070 50500 }
20071 else
20072 {
20073
2/2
✓ Branch 0 taken 49233 times.
✓ Branch 1 taken 415465 times.
464698 if(walkable)
20074 {
20075 415465 dx-=z3step-z3skip;
20076 415465 z3step=(z3step%2)+1;
20077 415465 }
20078 }
20079
20080 580644 break;
20081 }
20082 2028819 }
20083 else
20084 {
20085
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1268046 times.
✓ Branch 2 taken 1035601 times.
✓ Branch 3 taken 1490435 times.
✓ Branch 4 taken 1582627 times.
5376709 switch(d2)
20086 {
20087 case up:
20088
7/14
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 1267738 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 308 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 308 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 308 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
1268046 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
20089
20090 1268046 break;
20091
20092 case down:
20093
7/14
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1035547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 54 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 54 times.
1035601 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
20094
20095 1035601 break;
20096
20097 case left:
20098 1490435 dx-=xstep;
20099 1490435 break;
20100
20101 case right:
20102 1582627 dx+=xstep;
20103 1582627 break;
20104 }
20105 }
20106 7405528 }
20107
20108
8/16
✓ Branch 0 taken 25815 times.
✓ Branch 1 taken 7379769 times.
✓ Branch 2 taken 7379490 times.
✓ Branch 3 taken 26094 times.
✓ Branch 4 taken 7379289 times.
✓ Branch 5 taken 201 times.
✓ Branch 6 taken 7379289 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7379289 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
7405584 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
20109 {
20110 7379289 dir=d2;
20111 7379289 }
20112
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 26295 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
26295 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
20113 {
20114 dir = shiftdir;
20115 }
20116
20117
3/4
✓ Branch 0 taken 7304750 times.
✓ Branch 1 taken 100834 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7304750 times.
7405584 if(action != swimming && !IsSideSwim())
20118 {
20119 7304750 herostep();
20120
20121 //ack... don't walk if in midair! -DD
20122
12/14
✓ Branch 0 taken 7278935 times.
✓ Branch 1 taken 25815 times.
✓ Branch 2 taken 7278656 times.
✓ Branch 3 taken 279 times.
✓ Branch 4 taken 7268791 times.
✓ Branch 5 taken 9865 times.
✓ Branch 6 taken 7268791 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 149353 times.
✓ Branch 9 taken 7119438 times.
✓ Branch 10 taken 81755 times.
✓ Branch 11 taken 67598 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 81755 times.
7304750 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(this) && !getOnSideviewLadder()))
20123 {
20124 7187036 action=walking; FFCore.setHeroAction(walking);
20125 7187036 }
20126
20127
2/2
✓ Branch 0 taken 6914014 times.
✓ Branch 1 taken 390736 times.
7304750 if(++hero_count > (16*hero_animation_speed))
20128 390736 hero_count=0;
20129 7304750 }
20130
2/2
✓ Branch 0 taken 50397 times.
✓ Branch 1 taken 50437 times.
100834 else if(!(frame & 1))
20131 {
20132 50437 herostep();
20133 50437 }
20134
20135
3/4
✓ Branch 0 taken 25815 times.
✓ Branch 1 taken 7379769 times.
✓ Branch 2 taken 25815 times.
✗ Branch 3 not taken.
7405584 if(charging==0 || attack!=wHammer)
20136 {
20137 7405584 sprite::move((zfix)dx,(zfix)dy);
20138 7405584 }
20139 7405584 }
20140 7746046 void HeroClass::moveOld2(int32_t d2, int32_t forceRate)
20141 {
20142
4/6
✓ Branch 0 taken 7743447 times.
✓ Branch 1 taken 2599 times.
✓ Branch 2 taken 7743447 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7743447 times.
7746046 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
20143 2599 return;
20144
20145
3/4
✓ Branch 0 taken 7405584 times.
✓ Branch 1 taken 337863 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7405584 times.
7743447 if(!get_qr(qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
20146 {
20147 7405584 moveOld(d2);
20148 7405584 return;
20149 }
20150
20151
4/8
✓ Branch 0 taken 8657 times.
✓ Branch 1 taken 329206 times.
✓ Branch 2 taken 8657 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8657 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
667069 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS)) ||
20152
5/6
✓ Branch 0 taken 3681 times.
✓ Branch 1 taken 325525 times.
✓ Branch 2 taken 1575 times.
✓ Branch 3 taken 2106 times.
✓ Branch 4 taken 3681 times.
✗ Branch 5 not taken.
329206 (isSideViewHero() && (on_sideview_solid_oldpos(this)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
20153 //!DIMITODO: add QR for slow combos under hero
20154
4/4
✓ Branch 0 taken 329206 times.
✓ Branch 1 taken 8657 times.
✓ Branch 2 taken 8657 times.
✓ Branch 3 taken 17314 times.
355177 if(slowcombo) for (int32_t i = 0; i <= 1; ++i)
20155 {
20156
2/2
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 16730 times.
17314 if(tmpscr2[i].valid!=0)
20157 {
20158
2/2
✓ Branch 0 taken 11904 times.
✓ Branch 1 taken 4826 times.
16730 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20159 {
20160
2/4
✓ Branch 0 taken 11904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11904 times.
✗ Branch 3 not taken.
11904 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i])))
20161 {
20162 slowcombo = false;
20163 break;
20164 }
20165 11904 }
20166 else
20167 {
20168
2/4
✓ Branch 0 taken 4826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4826 times.
✗ Branch 3 not taken.
4826 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i])))
20169 {
20170 slowcombo = false;
20171 break;
20172 }
20173 }
20174 16730 }
20175 25971 }
20176
2/2
✓ Branch 0 taken 335594 times.
✓ Branch 1 taken 2269 times.
337863 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
20177 337863 bool is_swimming = (action == swimming);
20178 337863 bool fastSwim = (zinit.hero_swim_speed>60);
20179 337863 zfix rate(steprate);
20180 337863 int32_t shieldid = getCurrentActiveShield();
20181
1/2
✓ Branch 0 taken 337863 times.
✗ Branch 1 not taken.
337863 if(shieldid > -1)
20182 {
20183 itemdata const& shield = itemsbuf[shieldid];
20184 if(shield.flags & ITEM_FLAG10) //Change Speed flag
20185 {
20186 zfix perc = shield.misc7;
20187 perc /= 100;
20188 if(perc < 0)
20189 perc = (perc*-1)+1;
20190 rate = (rate * perc) + shield.misc8;
20191 }
20192 }
20193
20194 337863 zfix dx, dy;
20195 337863 zfix movepix(rate / 100);
20196 337863 zfix step(movepix);
20197 337863 zfix step_diag(movepix);
20198 337863 zfix up_step(game->get_sideswim_up() / -100.0);
20199 337863 zfix left_step(game->get_sideswim_side() / -100.0);
20200 337863 zfix right_step(game->get_sideswim_side() / 100.0);
20201 337863 zfix down_step(game->get_sideswim_down() / 100.0);
20202 337863 bool checkladder = false;
20203
20204
2/2
✓ Branch 0 taken 337661 times.
✓ Branch 1 taken 202 times.
337863 if(hero_newstep > movepix) hero_newstep = movepix;
20205
2/2
✓ Branch 0 taken 337661 times.
✓ Branch 1 taken 202 times.
337863 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
20206 //2/3 speed
20207
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 337863 times.
✓ Branch 2 taken 327019 times.
✓ Branch 3 taken 327019 times.
✓ Branch 4 taken 337863 times.
✓ Branch 5 taken 327019 times.
337863 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
20208 {
20209 664882 step = ((step / 3.0) * 2);
20210 664882 step_diag = ((step_diag / 3.0) * 2);
20211 664882 up_step = ((up_step / 3.0) * 2);
20212 664882 left_step = ((left_step / 3.0) * 2);
20213 664882 right_step = ((right_step / 3.0) * 2);
20214 664882 down_step = ((down_step / 3.0) * 2);
20215 664882 }
20216 //1/2 speed
20217
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 327019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✓ Branch 5 taken 326988 times.
327019 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
20218 {
20219 31 step /= 2;
20220 31 step_diag /= 2;
20221 31 up_step /= 2;
20222 31 left_step /= 2;
20223 31 right_step /= 2;
20224 31 down_step /= 2;
20225 31 }
20226 //normal speed
20227 else
20228 {
20229 //no modification
20230 }
20231
20232
1/2
✓ Branch 0 taken 337863 times.
✗ Branch 1 not taken.
337863 if(diagonalMovement)
20233 {
20234 //zprint2("Player's X is %d, Y is %d\n", x, y);
20235
6/6
✓ Branch 0 taken 265547 times.
✓ Branch 1 taken 72316 times.
✓ Branch 2 taken 281406 times.
✓ Branch 3 taken 15859 times.
✓ Branch 4 taken 124917 times.
✓ Branch 5 taken 228805 times.
513199 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
20236
4/4
✓ Branch 0 taken 207719 times.
✓ Branch 1 taken 191860 times.
✓ Branch 2 taken 16756 times.
✓ Branch 3 taken 190963 times.
15859 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
20237 {
20238
3/4
✓ Branch 0 taken 71344 times.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 71344 times.
529058 if(hero_newstep > 0 && hero_newstep_diag > 0)
20239 {
20240 71344 step = STEP_DIAGONAL(step);
20241 71344 step_diag = STEP_DIAGONAL(step_diag);
20242 71344 up_step = STEP_DIAGONAL(up_step);
20243 71344 left_step = STEP_DIAGONAL(left_step);
20244 71344 right_step = STEP_DIAGONAL(right_step);
20245 71344 down_step = STEP_DIAGONAL(down_step);
20246 71344 }
20247 71448 }
20248
2/2
✓ Branch 0 taken 229932 times.
✓ Branch 1 taken 32479 times.
262411 if(hero_newstep < step) step = hero_newstep; //handle collision
20249
2/2
✓ Branch 0 taken 251365 times.
✓ Branch 1 taken 11046 times.
262411 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
20250
5/5
✓ Branch 0 taken 75452 times.
✓ Branch 1 taken 72316 times.
✓ Branch 2 taken 69565 times.
✓ Branch 3 taken 96588 times.
✓ Branch 4 taken 99394 times.
262411 switch(d2)
20251 {
20252 case up:
20253
3/3
✓ Branch 0 taken 57008 times.
✓ Branch 1 taken 7436 times.
✓ Branch 2 taken 7872 times.
72316 switch(shiftdir)
20254 {
20255 case left:
20256 7436 dx = -step_diag;
20257
1/2
✓ Branch 0 taken 7436 times.
✗ Branch 1 not taken.
7436 if (IsSideSwim()) dx = left_step;
20258 7436 break;
20259 case right:
20260 7872 dx = step_diag;
20261
1/2
✓ Branch 0 taken 7872 times.
✗ Branch 1 not taken.
7872 if (IsSideSwim()) dx = right_step;
20262 7872 break;
20263 }
20264
2/2
✓ Branch 0 taken 10651 times.
✓ Branch 1 taken 61665 times.
72316 if(walkable)
20265 {
20266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61665 times.
61665 if (!IsSideSwim()) dy = -step;
20267
1/2
✓ Branch 0 taken 61665 times.
✗ Branch 1 not taken.
61665 if (IsSideSwim())
20268 {
20269 dy = up_step;
20270 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
20271 }
20272 61665 }
20273 72316 break;
20274 case down:
20275
3/3
✓ Branch 0 taken 51317 times.
✓ Branch 1 taken 9528 times.
✓ Branch 2 taken 8720 times.
69565 switch(shiftdir)
20276 {
20277 case left:
20278 9528 dx = -step_diag;
20279
1/2
✓ Branch 0 taken 9528 times.
✗ Branch 1 not taken.
9528 if (IsSideSwim()) dx = left_step;
20280 9528 break;
20281 case right:
20282 8720 dx = step_diag;
20283
1/2
✓ Branch 0 taken 8720 times.
✗ Branch 1 not taken.
8720 if (IsSideSwim()) dx = right_step;
20284 8720 break;
20285 }
20286
2/2
✓ Branch 0 taken 8345 times.
✓ Branch 1 taken 61220 times.
69565 if(walkable)
20287 {
20288 61220 dy = step;
20289
1/2
✓ Branch 0 taken 61220 times.
✗ Branch 1 not taken.
61220 if (IsSideSwim()) dy = down_step;
20290 61220 }
20291 69565 break;
20292 case left:
20293
3/3
✓ Branch 0 taken 77532 times.
✓ Branch 1 taken 10242 times.
✓ Branch 2 taken 8814 times.
96588 switch(shiftdir)
20294 {
20295 case up:
20296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10242 times.
10242 if (!IsSideSwim()) dy = -step_diag;
20297
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if (IsSideSwim())
20298 {
20299 dy = up_step;
20300 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
20301 }
20302 10242 break;
20303 case down:
20304 8814 dy = step_diag;
20305
1/2
✓ Branch 0 taken 8814 times.
✗ Branch 1 not taken.
8814 if (IsSideSwim()) dy = down_step;
20306 8814 break;
20307 }
20308
2/2
✓ Branch 0 taken 9075 times.
✓ Branch 1 taken 87513 times.
96588 if(walkable)
20309 {
20310 87513 dx = -step;
20311
1/2
✓ Branch 0 taken 87513 times.
✗ Branch 1 not taken.
87513 if (IsSideSwim()) dx = left_step;
20312 87513 }
20313 96588 break;
20314 case right:
20315
3/3
✓ Branch 0 taken 80558 times.
✓ Branch 1 taken 10404 times.
✓ Branch 2 taken 8432 times.
99394 switch(shiftdir)
20316 {
20317 case up:
20318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10404 times.
10404 if (!IsSideSwim()) dy = -step_diag;
20319
1/2
✓ Branch 0 taken 10404 times.
✗ Branch 1 not taken.
10404 if (IsSideSwim())
20320 {
20321 dy = up_step;
20322 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
20323 }
20324 10404 break;
20325 case down:
20326 8432 dy = step_diag;
20327
1/2
✓ Branch 0 taken 8432 times.
✗ Branch 1 not taken.
8432 if (IsSideSwim()) dy = down_step;
20328 8432 break;
20329 }
20330
2/2
✓ Branch 0 taken 9683 times.
✓ Branch 1 taken 89711 times.
99394 if(walkable)
20331 {
20332 89711 dx = step;
20333
1/2
✓ Branch 0 taken 89711 times.
✗ Branch 1 not taken.
89711 if (IsSideSwim()) dx = right_step;
20334 89711 }
20335 99394 break;
20336 };
20337 413315 }
20338 else
20339 {
20340 if(hero_newstep < step) step = hero_newstep; //handle collision
20341 switch(d2)
20342 {
20343 case up:
20344 dy -= step;
20345 if (IsSideSwim()) dy = up_step;
20346 break;
20347 case down:
20348 dy += step;
20349 if (IsSideSwim()) dy = down_step;
20350 break;
20351 case left:
20352 dx -= step;
20353 if (IsSideSwim()) dx = left_step;
20354 break;
20355 case right:
20356 dx += step;
20357 if (IsSideSwim()) dx = right_step;
20358 break;
20359 };
20360 }
20361 413315 hero_newstep = movepix;
20362 413315 hero_newstep_diag = movepix;
20363
20364
7/16
✓ Branch 0 taken 2269 times.
✓ Branch 1 taken 411046 times.
✓ Branch 2 taken 335594 times.
✓ Branch 3 taken 77721 times.
✓ Branch 4 taken 335594 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 335594 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 335594 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
413315 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
20365 {
20366 335594 dir=d2;
20367 335594 }
20368
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 77721 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
77721 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
20369 {
20370 dir = shiftdir;
20371 }
20372
2/2
✓ Branch 0 taken 413058 times.
✓ Branch 1 taken 257 times.
413315 if(forceRate > -1)
20373 {
20374 257 checkladder = false;
20375
2/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 245 times.
257 switch(dir)
20376 {
20377 case right:
20378 case r_up:
20379 case r_down:
20380 12 dx = zfix(forceRate) / 100;
20381 12 break;
20382 case left:
20383 case l_up:
20384 case l_down:
20385 dx = zfix(-forceRate) / 100;
20386 break;
20387 default:
20388 245 dx = 0;
20389 245 }
20390
3/3
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 12 times.
257 switch(dir)
20391 {
20392 case down:
20393 case r_down:
20394 case l_down:
20395 17 dy = zfix(forceRate) / 100;
20396 17 break;
20397 case up:
20398 case r_up:
20399 case l_up:
20400 228 dy = zfix(-forceRate) / 100;
20401 228 break;
20402 default:
20403 12 dy = 0;
20404 12 }
20405 257 }
20406
4/4
✓ Branch 0 taken 3681 times.
✓ Branch 1 taken 409634 times.
✓ Branch 2 taken 2574 times.
✓ Branch 3 taken 1107 times.
413315 if (isSideViewHero() && slopeid)
20407 {
20408 1107 dy += (dx * slopeid);
20409 1107 }
20410
4/4
✓ Branch 0 taken 127341 times.
✓ Branch 1 taken 285974 times.
✓ Branch 2 taken 100899 times.
✓ Branch 3 taken 26442 times.
413315 if(dx == 0 && dy == 0) return;
20411
5/8
✓ Branch 0 taken 311421 times.
✓ Branch 1 taken 75452 times.
✓ Branch 2 taken 311421 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 311421 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 311421 times.
386873 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
20412 {
20413 311421 herostep();
20414
20415 //ack... don't walk if in midair! -DD
20416
11/14
✓ Branch 0 taken 309418 times.
✓ Branch 1 taken 2003 times.
✓ Branch 2 taken 309418 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 306273 times.
✓ Branch 5 taken 3145 times.
✓ Branch 6 taken 306273 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3585 times.
✓ Branch 9 taken 302688 times.
✓ Branch 10 taken 1524 times.
✓ Branch 11 taken 2061 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1524 times.
311421 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(this) && !getOnSideviewLadder()))
20417 {
20418 304749 action=walking; FFCore.setHeroAction(walking);
20419 304749 }
20420
20421
2/2
✓ Branch 0 taken 295088 times.
✓ Branch 1 taken 16333 times.
311421 if(++hero_count > (16*hero_animation_speed))
20422 16333 hero_count=0;
20423 311421 }
20424
1/2
✓ Branch 0 taken 75452 times.
✗ Branch 1 not taken.
75452 else if(!(frame & 1))
20425 {
20426 herostep();
20427 }
20428
20429
4/4
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 384870 times.
✓ Branch 2 taken 73449 times.
✓ Branch 3 taken 71446 times.
386873 if(charging==0 || attack!=wHammer)
20430 {
20431 458319 sprite::move(dx, dy);
20432 458319 WalkflagInfo info;
20433 458319 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
20434 458319 execute(info);
20435
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 311421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 311421 times.
✗ Branch 7 not taken.
458319 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
20436 {
20437 if (game->get_sideswim_jump() != 0)
20438 {
20439 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
20440 sfx(WAV_ZN1SPLASH,(int32_t)x);
20441 hopclk = 0;
20442 if (charging || spins) action = attacking;
20443 else action = none;
20444 }
20445 else
20446 {
20447 sprite::move(0_zf, zfix(-1*dy));
20448 }
20449 }
20450 311421 }
20451 7817492 }
20452
20453 32249683 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
20454 {
20455 32249683 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
20456 }
20457 32249683 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
20458 {
20459 32249683 WalkflagInfo ret;
20460
20461 32249683 wx = vbound(wx, -1, 256);
20462 32249683 wy = vbound(wy, -1, 176);
20463
20464
8/8
✓ Branch 0 taken 32158725 times.
✓ Branch 1 taken 90958 times.
✓ Branch 2 taken 32070143 times.
✓ Branch 3 taken 88582 times.
✓ Branch 4 taken 32069850 times.
✓ Branch 5 taken 293 times.
✓ Branch 6 taken 7816 times.
✓ Branch 7 taken 32062034 times.
32249683 if (wx < 0 || wx > 255 || wy < 0 || wy > 175)
20465 {
20466 187649 ret.setUnwalkable(false);
20467 187649 return ret;
20468 }
20469
20470
2/2
✓ Branch 0 taken 44786 times.
✓ Branch 1 taken 32017248 times.
32062034 if(toogam)
20471 {
20472 44786 ret.setUnwalkable(false);
20473 44786 return ret;
20474 }
20475
20476
4/4
✓ Branch 0 taken 547172 times.
✓ Branch 1 taken 31470076 times.
✓ Branch 2 taken 522138 times.
✓ Branch 3 taken 25034 times.
32017248 if(blockpath && wy<(bigHitbox?80:88))
20477 {
20478 25034 ret.setUnwalkable(true);
20479 25034 return ret;
20480 }
20481
20482
4/4
✓ Branch 0 taken 495981 times.
✓ Branch 1 taken 31496233 times.
✓ Branch 2 taken 311830 times.
✓ Branch 3 taken 184151 times.
31992214 if(mblock2.active() && mblock2.hit(wx,wy,0,1,1,1))
20483 {
20484 184151 ret.setUnwalkable(true);
20485 184151 return ret;
20486 }
20487
20488
2/2
✓ Branch 0 taken 1100 times.
✓ Branch 1 taken 31806963 times.
31808063 if (collide_object(wx, wy,1, 1))
20489 {
20490 1100 ret.setUnwalkable(true);
20491 1100 return ret;
20492 }
20493
20494
18/22
✓ Branch 0 taken 15315978 times.
✓ Branch 1 taken 16490985 times.
✓ Branch 2 taken 14864485 times.
✓ Branch 3 taken 451493 times.
✓ Branch 4 taken 14343421 times.
✓ Branch 5 taken 521064 times.
✓ Branch 6 taken 517666 times.
✓ Branch 7 taken 3398 times.
✓ Branch 8 taken 517666 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 517666 times.
✓ Branch 12 taken 2095 times.
✓ Branch 13 taken 1303 times.
✓ Branch 14 taken 281864 times.
✓ Branch 15 taken 239200 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 239200 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 239200 times.
✓ Branch 20 taken 31084 times.
✓ Branch 21 taken 31775879 times.
32119269 if(isdungeon() && currscr<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
20495
2/2
✓ Branch 0 taken 30442 times.
✓ Branch 1 taken 208758 times.
521064 && !get_qr(qr_FREEFORM))
20496 {
20497 31084 ret.setUnwalkable(true);
20498 31084 return ret;
20499 }
20500
20501
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31775879 times.
✓ Branch 2 taken 31775879 times.
✗ Branch 3 not taken.
31775879 bool wf = _walkflag(wx,wy,cnt,SWITCHBLOCK_STATE);
20502
20503
6/6
✓ Branch 0 taken 15284894 times.
✓ Branch 1 taken 16490985 times.
✓ Branch 2 taken 14833401 times.
✓ Branch 3 taken 451493 times.
✓ Branch 4 taken 6357215 times.
✓ Branch 5 taken 8476186 times.
31775879 if(isdungeon() && currscr<128 && !get_qr(qr_FREEFORM))
20504 {
20505
3/6
✓ Branch 0 taken 8476186 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8476186 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8476186 times.
8476186 if((diagonalMovement||NO_GRIDLOCK))
20506 {
20507 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
20508
20509 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
20510 }
20511 8476186 }
20512 //All problems related to exiting water are probably here. -Z
20513
3/4
✓ Branch 0 taken 31098549 times.
✓ Branch 1 taken 677330 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31098549 times.
31775879 if(action==swimming || IsSideSwim())
20514 {
20515
2/2
✓ Branch 0 taken 645181 times.
✓ Branch 1 taken 32149 times.
677330 if(!wf)
20516 {
20517 32149 bool isthissolid = false;
20518
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 32149 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32149 times.
✓ Branch 4 taken 5887 times.
✓ Branch 5 taken 26262 times.
38460 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
20519
4/6
✓ Branch 0 taken 25838 times.
✓ Branch 1 taken 6311 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6311 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6311 times.
32149 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
20520
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 6289 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6289 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6289 times.
6311 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
20521
4/6
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 5887 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5887 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5887 times.
32551 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
20522 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
20523
20524
20525
5/6
✓ Branch 0 taken 7310 times.
✓ Branch 1 taken 24839 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7310 times.
✓ Branch 4 taken 14729 times.
✓ Branch 5 taken 46086 times.
56988 if(landswim>= (get_qr(qr_DROWN) && isSwimming() ? 1
20526
2/2
✓ Branch 0 taken 2107 times.
✓ Branch 1 taken 22732 times.
24839 : (!diagonalMovement) ? 1 : (get_qr(qr_NO_HOPPING)?1:22)))
20527 {
20528 //Check for out of bounds for swimming
20529 14729 bool changehop = true;
20530
20531
5/6
✓ Branch 0 taken 1828 times.
✓ Branch 1 taken 12901 times.
✓ Branch 2 taken 1828 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12828 times.
✓ Branch 5 taken 11732 times.
14729 if((diagonalMovement||NO_GRIDLOCK))
20532 {
20533
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
25729 if(wx<0||wy<0)
20534 changehop = false;
20535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 else if(wx>248)
20536 changehop = false;
20537
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
73 else if(wx>240&&cnt==2)
20538 changehop = false;
20539
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 3 times.
73 else if(wy>168)
20540 3 changehop = false;
20541 73 }
20542
3/4
✓ Branch 0 taken 1901 times.
✓ Branch 1 taken 9904 times.
✓ Branch 2 taken 11805 times.
✗ Branch 3 not taken.
11805 if ((get_qr(qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
20543 //This may be where the hang-up for exiting water exists. -Z
20544 // hop out of the water
20545
2/2
✓ Branch 0 taken 9907 times.
✓ Branch 1 taken 1898 times.
11805 if(changehop)
20546 1898 ret.setHopClk(1);
20547 11805 }
20548 else
20549 {
20550
6/6
✓ Branch 0 taken 26109 times.
✓ Branch 1 taken 19977 times.
✓ Branch 2 taken 25289 times.
✓ Branch 3 taken 20797 times.
✓ Branch 4 taken 16813 times.
✓ Branch 5 taken 8476 times.
46086 if((!(get_qr(qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
20551 {
20552 //int32_t vx=((int32_t)x+4)&0xFFF8;
20553 //int32_t vy=((int32_t)y+4)&0xFFF8;
20554
2/2
✓ Branch 0 taken 1936 times.
✓ Branch 1 taken 7515 times.
25289 if(d2==left)
20555 {
20556
4/4
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1656 times.
✓ Branch 3 taken 280 times.
3596 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?6:11)), currmap, currscr, -1, x-1,y+(bigHitbox?6:11)) &&
20557
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1658 times.
1660 !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?9:12)), currmap, currscr, -1, x-1,y+(bigHitbox?9:12)) &&
20558
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1658 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1658 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1656 times.
1658 !_walkflag(x-1,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
20559
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1656 times.
1656 !_walkflag(x-1,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
20560 {
20561 1656 ret.setHopDir(d2);
20562 1656 ret.setIlswim(true);
20563 1656 }
20564 280 else ret.setIlswim(false);
20565 1936 }
20566
2/2
✓ Branch 0 taken 5751 times.
✓ Branch 1 taken 1764 times.
7515 else if(d2==right)
20567 {
20568
4/4
✓ Branch 0 taken 1654 times.
✓ Branch 1 taken 4097 times.
✓ Branch 2 taken 1654 times.
✓ Branch 3 taken 4097 times.
7405 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?6:11)), currmap, currscr, -1, x+16,y+(bigHitbox?6:11)) &&
20569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1654 times.
1654 !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?9:12)), currmap, currscr, -1, x+16,y+(bigHitbox?9:12)) &&
20570
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1654 times.
1654 !_walkflag(x+16,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
20571
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654 times.
1654 !_walkflag(x+16,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
20572 {
20573 1654 ret.setHopDir(d2);
20574 1654 ret.setIlswim(true);
20575 1654 }
20576 4097 else ret.setIlswim(false);
20577 5751 }
20578
2/2
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 762 times.
1764 else if(d2==up)
20579 {
20580
4/4
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 221 times.
✓ Branch 2 taken 539 times.
✓ Branch 3 taken 223 times.
1303 if(!iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1) &&
20581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 541 times.
541 !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1) &&
20582
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 541 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 541 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 539 times.
541 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
20583
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 539 times.
539 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
20584 {
20585 539 ret.setHopDir(d2);
20586 539 ret.setIlswim(true);
20587 539 }
20588 223 else ret.setIlswim(false);
20589 762 }
20590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 else if(d2==down)
20591 {
20592
4/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 651 times.
✓ Branch 2 taken 351 times.
✓ Branch 3 taken 651 times.
1353 if(!iswaterex(MAPCOMBO(x+7,y+16), currmap, currscr, -1, x+7,y+16) &&
20593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
351 !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16) &&
20594
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 351 times.
351 !_walkflag(x+7,y+16,1,SWITCHBLOCK_STATE) &&
20595
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 !_walkflag(x+8,y+16,1,SWITCHBLOCK_STATE))
20596 {
20597 351 ret.setHopDir(d2);
20598 351 ret.setIlswim(true);
20599 351 }
20600 651 else ret.setIlswim(false);
20601 1002 }
20602 9451 }
20603
20604
2/4
✓ Branch 0 taken 30248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30248 times.
30248 if(wx<0||wy<0);
20605
2/2
✓ Branch 0 taken 4422 times.
✓ Branch 1 taken 25826 times.
30248 else if(wx>248);
20606
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25826 else if(wx>240&&cnt==2);
20607
2/2
✓ Branch 0 taken 774 times.
✓ Branch 1 taken 25052 times.
25826 else if(wy>168);
20608
4/4
✓ Branch 0 taken 6428 times.
✓ Branch 1 taken 18624 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 6399 times.
25052 else if(get_qr(qr_DROWN) && !ilswim);
20609 //if(iswaterex(MAPCOMBO(wx,wy)) && iswaterex(MAPCOMBO(wx,wy)))
20610
2/2
✓ Branch 0 taken 17095 times.
✓ Branch 1 taken 1558 times.
18653 else if(iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
20611 {
20612 1558 ret.setUnwalkable(false);
20613 1558 return ret;
20614 }
20615 else
20616 {
20617 17095 ret.setUnwalkable(true);
20618 17095 return ret;
20619 }
20620 }
20621 23400 }
20622 else
20623 {
20624 645181 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
20625 645181 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Is x + 8 intentional???
20626
20627
8/8
✓ Branch 0 taken 595014 times.
✓ Branch 1 taken 50167 times.
✓ Branch 2 taken 537287 times.
✓ Branch 3 taken 57727 times.
✓ Branch 4 taken 50167 times.
✓ Branch 5 taken 57727 times.
✓ Branch 6 taken 39371 times.
✓ Branch 7 taken 10796 times.
645181 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
20628 {
20629 576658 ret.setUnwalkable(false);
20630 576658 return ret;
20631 }
20632 }
20633 91923 }
20634
2/2
✓ Branch 0 taken 384504 times.
✓ Branch 1 taken 30714045 times.
31098549 else if(ladderx+laddery) // ladder is being used
20635 {
20636
8/10
✓ Branch 0 taken 27069 times.
✓ Branch 1 taken 357435 times.
✓ Branch 2 taken 25080 times.
✓ Branch 3 taken 1989 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1989 times.
✓ Branch 6 taken 1989 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1936 times.
✓ Branch 9 taken 53 times.
384504 int32_t lx = !(get_qr(qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wx) : x;
20637
8/10
✓ Branch 0 taken 27069 times.
✓ Branch 1 taken 357435 times.
✓ Branch 2 taken 25080 times.
✓ Branch 3 taken 1989 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1989 times.
✓ Branch 6 taken 1989 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1936 times.
✓ Branch 9 taken 53 times.
384504 int32_t ly = !(get_qr(qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wy) : y;
20638
20639
4/6
✓ Branch 0 taken 363296 times.
✓ Branch 1 taken 21208 times.
✓ Branch 2 taken 363296 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 363296 times.
384504 if((diagonalMovement||NO_GRIDLOCK))
20640 {
20641
2/2
✓ Branch 0 taken 13575 times.
✓ Branch 1 taken 7633 times.
21208 if(ladderdir==up)
20642 {
20643
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 4270 times.
7633 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
20644 {
20645 4270 bool temp = false;
20646
20647
2/2
✓ Branch 0 taken 1391 times.
✓ Branch 1 taken 2879 times.
4270 if(!(abs(lx-(ladderx+8))<=8))
20648 2879 temp = true;
20649
20650
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 980 times.
4270 if(cnt==2)
20651
1/2
✓ Branch 0 taken 980 times.
✗ Branch 1 not taken.
980 if(!(abs((lx+8)-(ladderx+8))<=8))
20652 temp=true;
20653
20654
2/2
✓ Branch 0 taken 2879 times.
✓ Branch 1 taken 1391 times.
4270 if(!temp)
20655 {
20656 1391 ret.setUnwalkable(false);
20657 1391 return ret;
20658 }
20659
20660
5/6
✓ Branch 0 taken 2879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2125 times.
✓ Branch 3 taken 754 times.
✓ Branch 4 taken 122 times.
✓ Branch 5 taken 2757 times.
2879 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
20661 {
20662 2757 ret.setUnwalkable(true);
20663 2757 return ret;
20664 }
20665 122 }
20666 3485 }
20667 else
20668 {
20669
2/2
✓ Branch 0 taken 7020 times.
✓ Branch 1 taken 6555 times.
13575 if(abs(lx-(ladderx+8))<=8)
20670 {
20671
2/2
✓ Branch 0 taken 4323 times.
✓ Branch 1 taken 2232 times.
6555 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
20672 {
20673 4323 ret.setUnwalkable(false);
20674 4323 return ret;
20675 }
20676
20677
6/6
✓ Branch 0 taken 2220 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1785 times.
✓ Branch 3 taken 435 times.
✓ Branch 4 taken 916 times.
✓ Branch 5 taken 869 times.
2232 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
20678 {
20679 1351 ret.setUnwalkable(true);
20680 1351 return ret;
20681 }
20682
20683
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
881 if((abs(ly-laddery+8)<=8) && d2<=down)
20684 {
20685 ret.setUnwalkable(false);
20686 return ret;
20687 }
20688 881 }
20689 }
20690 11386 } // diagonalMovement
20691 else
20692 {
20693
2/2
✓ Branch 0 taken 222358 times.
✓ Branch 1 taken 140938 times.
363296 if((d2&2)==ladderdir) // same direction
20694 {
20695
3/3
✓ Branch 0 taken 13729 times.
✓ Branch 1 taken 196539 times.
✓ Branch 2 taken 12090 times.
222358 switch(d2)
20696 {
20697 case up:
20698
2/2
✓ Branch 0 taken 8605 times.
✓ Branch 1 taken 3485 times.
12090 if(y.getInt()<=laddery)
20699 {
20700
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8605 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8605 times.
✓ Branch 4 taken 970 times.
✓ Branch 5 taken 7635 times.
16240 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,SWITCHBLOCK_STATE) ||
20701
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7635 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7635 times.
7635 _walkflag(ladderx+8,laddery-8,1,SWITCHBLOCK_STATE));
20702 8605 return ret;
20703
20704 }
20705
20706 [[fallthrough]];
20707 case down:
20708
2/2
✓ Branch 0 taken 9176 times.
✓ Branch 1 taken 8038 times.
17214 if((wy&0xF0)==laddery)
20709 {
20710 9176 ret.setUnwalkable(false);
20711 9176 return ret;
20712 }
20713
20714 8038 break;
20715
20716 default:
20717
2/2
✓ Branch 0 taken 74354 times.
✓ Branch 1 taken 122185 times.
196539 if((wx&0xF0)==ladderx)
20718 {
20719 74354 ret.setUnwalkable(false);
20720 74354 return ret;
20721 }
20722 122185 }
20723
20724
2/2
✓ Branch 0 taken 8038 times.
✓ Branch 1 taken 122185 times.
130223 if(d2<=down)
20725 {
20726
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 8038 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8038 times.
✓ Branch 4 taken 1060 times.
✓ Branch 5 taken 6978 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6978 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 6978 times.
8038 ret.setUnwalkable(_walkflag(ladderx,wy,1,SWITCHBLOCK_STATE) || _walkflag(ladderx+8,wy,1,SWITCHBLOCK_STATE));
20727 8038 return ret;
20728 }
20729
20730
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 122185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122185 times.
✓ Branch 4 taken 29654 times.
✓ Branch 5 taken 92531 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 92531 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 92531 times.
122185 ret.setUnwalkable(_walkflag((wx&0xF0),wy,1,SWITCHBLOCK_STATE) || _walkflag((wx&0xF0)+8,wy,1,SWITCHBLOCK_STATE));
20731 122185 return ret;
20732 }
20733
20734 // different dir
20735
3/8
✓ Branch 0 taken 140509 times.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 140509 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
140938 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
20736 {
20737 140509 ret.setUnwalkable(true);
20738 140509 return ret;
20739 }
20740
20741
5/6
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 20 times.
429 if(wy>=laddery && wy<=laddery+16 && d2<=down)
20742 {
20743 20 ret.setUnwalkable(false);
20744 20 return ret;
20745 }
20746 }
20747 11795 }
20748
6/6
✓ Branch 0 taken 25437252 times.
✓ Branch 1 taken 5276793 times.
✓ Branch 2 taken 25127872 times.
✓ Branch 3 taken 309380 times.
✓ Branch 4 taken 6559472 times.
✓ Branch 5 taken 18568400 times.
30714045 else if(wf || isSideViewHero() || get_qr(qr_DROWN))
20749 {
20750 // see if it's a good spot for the ladder or for swimming
20751
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12145645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12145645 times.
12145645 bool unwalkablex = _walkflag(wx,wy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
20752
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12145645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12145645 times.
12145645 bool unwalkablex8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE);
20753
20754
2/2
✓ Branch 0 taken 3561888 times.
✓ Branch 1 taken 8583757 times.
12145645 if(get_qr(qr_DROWN))
20755 {
20756 // Drowning changes the following attributes:
20757 // * Dangerous water is also walkable, so ignore the previous
20758 // definitions of unwalkablex and unwalkablex8.
20759 // * Instead, prevent the ladder from being used in the
20760 // one frame where Hero has landed on water before drowning.
20761 8583757 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
20762 8583757 }
20763
20764 // check if he can swim
20765
5/6
✓ Branch 0 taken 2403405 times.
✓ Branch 1 taken 9742240 times.
✓ Branch 2 taken 2400441 times.
✓ Branch 3 taken 2964 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2400441 times.
12145645 if(current_item(itype_flippers) && z==0 && fakez==0)
20766 {
20767 2400441 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
20768 2400441 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
20769
2/6
✓ Branch 0 taken 2400441 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2400441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2400441 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
20770 {
20771 //ladder ignores water combos that are now walkable thanks to flippers -DD
20772
2/2
✓ Branch 0 taken 13116 times.
✓ Branch 1 taken 2387325 times.
2400441 unwalkablex = unwalkablex && (!wtrx);
20773
2/2
✓ Branch 0 taken 1358997 times.
✓ Branch 1 taken 1041444 times.
2400441 unwalkablex8 = unwalkablex8 && (!wtrx8);
20774
20775
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2400379 times.
2400441 if(landswim >= 22)
20776 {
20777 62 ret.setHopClk(2);
20778 62 ret.setUnwalkable(false);
20779 62 return ret;
20780 }
20781
8/8
✓ Branch 0 taken 2102621 times.
✓ Branch 1 taken 297758 times.
✓ Branch 2 taken 17578 times.
✓ Branch 3 taken 2085043 times.
✓ Branch 4 taken 297758 times.
✓ Branch 5 taken 2085043 times.
✓ Branch 6 taken 1874 times.
✓ Branch 7 taken 295884 times.
2400379 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
20782 {
20783
4/6
✓ Branch 0 taken 12538 times.
✓ Branch 1 taken 6914 times.
✓ Branch 2 taken 12538 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12538 times.
19452 if(!(diagonalMovement||NO_GRIDLOCK))
20784 {
20785 12538 ret.setHopClk(2);
20786
20787
2/4
✓ Branch 0 taken 12538 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12538 times.
12538 if(charging || spins>5)
20788 {
20789 //if Hero is charging, he might be facing the wrong direction (we want him to
20790 //hop into the water, not in the facing direction)
20791 ret.setDir(d2);
20792 //moreover Hero can't charge in the water -DD
20793 ret.setChargeAttack();
20794 }
20795
20796 12538 ret.setUnwalkable(false);
20797 12538 return ret;
20798 }
20799
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 6391 times.
6914 else if(dir==d2)
20800 {
20801 6391 ret.setIlswim(true);
20802 6391 ladderx = 0;
20803 6391 laddery = 0;
20804 6391 }
20805 6914 }
20806 2387841 }
20807 2387841 }
20808
20809 // check if he can use the ladder
20810 // "Allow Ladder Anywhere" is toggled by fLADDER
20811
2/2
✓ Branch 0 taken 9282627 times.
✓ Branch 1 taken 2850418 times.
12133045 if(can_deploy_ladder())
20812 // laddersetup
20813 {
20814 // Check if there's water to use the ladder over
20815 2850418 bool wtrx = (iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy) != 0);
20816 2850418 bool wtrx8 = (iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy) != 0);
20817 2850418 int32_t ldrid = current_item_id(itype_ladder);
20818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2850418 times.
2850418 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
20819
20820
4/4
✓ Branch 0 taken 2840505 times.
✓ Branch 1 taken 9913 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 2840452 times.
2850418 if(wtrx || wtrx8)
20821 {
20822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9966 times.
9966 if(isSideViewHero())
20823 {
20824 wtrx = !_walkflag(wx, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
20825 wtrx8 = !_walkflag(wx+8, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx+8, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
20826 }
20827 // * walk on half-water using the ladder instead of using flippers.
20828 // * otherwise, walk on ladder(+hookshot) combos.
20829
3/8
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 9371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9966 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
20830 {
20831
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 464 times.
595 if(!get_qr(qr_OLD_210_WATER))
20832 {
20833 //if Hero could swim on a tile instead of using the ladder,
20834 //refuse to use the ladder to step over that tile. -DD
20835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 464 times.
464 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
20836
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 458 times.
464 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
20837 464 }
20838 595 }
20839 9966 }
20840 else
20841 {
20842 // No water; check other things
20843
20844 //Check pits
20845
2/2
✓ Branch 0 taken 2839425 times.
✓ Branch 1 taken 1027 times.
2840452 if(ladderpits)
20846 {
20847 1027 int32_t pit_cmb = getpitfall(wx,wy);
20848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
20849 1027 pit_cmb = getpitfall(x+8,wy);
20850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
20851 1027 }
20852
4/6
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 2839425 times.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✗ Branch 5 not taken.
2840452 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
20853 {
20854 2840452 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
20855
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 2840266 times.
2840452 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
20856 2840452 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
20857
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 2840160 times.
2840452 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
20858 2840452 }
20859 }
20860
20861
2/2
✓ Branch 0 taken 5700836 times.
✓ Branch 1 taken 2850418 times.
8551254 for (int32_t i = 0; i <= 1; ++i)
20862 {
20863
2/2
✓ Branch 0 taken 4346208 times.
✓ Branch 1 taken 1354628 times.
5700836 if(tmpscr2[i].valid!=0)
20864 {
20865
2/2
✓ Branch 0 taken 1303366 times.
✓ Branch 1 taken 51262 times.
1354628 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20866 {
20867
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1303366 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1303366 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
20868
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1303366 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1303366 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
20869 1303366 }
20870 else
20871 {
20872
3/4
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 51003 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
51262 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
20873
3/4
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 51025 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 237 times.
51262 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
20874 }
20875 1354628 }
20876 5700836 }
20877
2/2
✓ Branch 0 taken 2062784 times.
✓ Branch 1 taken 787634 times.
2850418 bool walkwater = (get_qr(qr_DROWN) && !iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy));
20878
20879
4/6
✓ Branch 0 taken 2202746 times.
✓ Branch 1 taken 647672 times.
✓ Branch 2 taken 2202746 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2202746 times.
2850418 if((diagonalMovement||NO_GRIDLOCK))
20880 {
20881
2/2
✓ Branch 0 taken 109936 times.
✓ Branch 1 taken 537736 times.
647672 if(d2==dir)
20882 {
20883 537736 int32_t c = walkwater ? 0:8;
20884 537736 int32_t b = walkwater ? 8:0;
20885
20886
2/2
✓ Branch 0 taken 347962 times.
✓ Branch 1 taken 189774 times.
537736 if(d2>=left)
20887 {
20888 // If the difference between wy and y is small enough
20889
4/4
✓ Branch 0 taken 102382 times.
✓ Branch 1 taken 245580 times.
✓ Branch 2 taken 347804 times.
✓ Branch 3 taken 158 times.
347962 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
20890 {
20891 // Don't activate the ladder if it would be entirely
20892 // over water and Hero has the flippers. This isn't
20893 // a good way to do this, but it's too risky
20894 // to make big changes to this stuff.
20895 158 bool deployLadder=true;
20896 158 int32_t lx=wx&0xF0;
20897
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 156 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 156 times.
✓ Branch 7 taken 2 times.
158 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
20898 {
20899
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
20900 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
20901 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
20902 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
20903 deployLadder=false;
20904 2 }
20905
1/2
✓ Branch 0 taken 158 times.
✗ Branch 1 not taken.
158 if(deployLadder)
20906 {
20907 158 ladderx = wx&0xF0;
20908 158 laddery = y;
20909 158 ladderdir = left;
20910 158 ladderstart = d2;
20911 158 ret.setUnwalkable(laddery!=y.getInt());
20912 158 return ret;
20913 }
20914 }
20915 347804 }
20916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189774 times.
189774 else if(d2<=down)
20917 {
20918 // If the difference between wx and x is small enough
20919
4/4
✓ Branch 0 taken 75665 times.
✓ Branch 1 taken 114109 times.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 189687 times.
189774 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
20920 {
20921 87 ladderx = x;
20922 87 laddery = wy&0xF0;
20923 87 ladderdir = up;
20924 87 ladderstart = d2;
20925 87 ret.setUnwalkable(ladderx!=x.getInt());
20926 87 return ret;
20927 }
20928
20929
2/2
✓ Branch 0 taken 75624 times.
✓ Branch 1 taken 114063 times.
189687 if(cnt==2)
20930 {
20931
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114063 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 114046 times.
114063 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
20932 {
20933 17 ladderx = x;
20934 17 laddery = wy&0xF0;
20935 17 ladderdir = up;
20936 17 ladderstart = d2;
20937 17 ret.setUnwalkable(ladderx!=x.getInt());
20938 17 return ret;
20939 }
20940 114046 }
20941 189670 }
20942 537474 }
20943 647410 }
20944 else
20945 {
20946
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2202746 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2202746 times.
✓ Branch 4 taken 116610 times.
✓ Branch 5 taken 2086136 times.
2202746 bool flgx = _walkflag(wx,wy,1,SWITCHBLOCK_STATE) && !wtrx; // Solid, and not steppable
20947
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2202746 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2202746 times.
✓ Branch 4 taken 2016027 times.
✓ Branch 5 taken 186719 times.
2202746 bool flgx8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE) && !wtrx8; // Solid, and not steppable
20948
20949
2/2
✓ Branch 0 taken 2040145 times.
✓ Branch 1 taken 162601 times.
2202818 if((d2>=left && wtrx)
20950 // Deploy the ladder vertically even if Hero is only half on water.
20951
8/8
✓ Branch 0 taken 18496 times.
✓ Branch 1 taken 2021649 times.
✓ Branch 2 taken 162601 times.
✓ Branch 3 taken 2021649 times.
✓ Branch 4 taken 1222 times.
✓ Branch 5 taken 161379 times.
✓ Branch 6 taken 72 times.
✓ Branch 7 taken 162529 times.
2202746 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
20952 {
20953
4/4
✓ Branch 0 taken 17936 times.
✓ Branch 1 taken 560 times.
✓ Branch 2 taken 697 times.
✓ Branch 3 taken 17239 times.
18496 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
20954 1257 ladderdir = up;
20955 else
20956 17239 ladderdir = left;
20957
20958
2/2
✓ Branch 0 taken 17239 times.
✓ Branch 1 taken 1257 times.
18496 if(ladderdir==up)
20959 {
20960 1257 ladderx = x.getInt()&0xF8;
20961 1257 laddery = wy&0xF0;
20962 1257 }
20963 else
20964 {
20965 17239 ladderx = wx&0xF0;
20966 17239 laddery = y.getInt()&0xF8;
20967 }
20968
20969 18496 ret.setUnwalkable(false);
20970 18496 return ret;
20971 }
20972 }
20973 2831660 }
20974 12114287 }
20975
20976 30786405 ret.setUnwalkable(wf);
20977 30786405 return ret;
20978 32259587 }
20979
20980 // Only checks for moving blocks. Apparently this is a thing we need.
20981 3039467 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
20982 {
20983 3039467 HeroClass::WalkflagInfo ret;
20984
2/2
✓ Branch 0 taken 47377 times.
✓ Branch 1 taken 2992090 times.
3039467 if (!mblock2.active()) //Without this, weird swimming behaviors happen.
20985 {
20986 2992090 ret.setFlags(~1);
20987 2992090 ret.setHopDir(-1);
20988 2992090 }
20989
2/2
✓ Branch 0 taken 2807 times.
✓ Branch 1 taken 3036660 times.
3039467 if(toogam) return ret;
20990
2/2
✓ Branch 0 taken 2989283 times.
✓ Branch 1 taken 47377 times.
3036660 if (mblock2.active())
20991 47377 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
20992
2/2
✓ Branch 0 taken 3036410 times.
✓ Branch 1 taken 250 times.
3036660 if (collide_object(wx, wy,1, 1))
20993 250 ret.setUnwalkable(true);
20994 3036660 return ret;
20995 3039467 }
20996
20997 13979847 bool HeroClass::checksoliddamage()
20998 {
20999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13979847 times.
13979847 if(toogam) return false;
21000
21001
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13979847 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13979847 if (get_qr(qr_NO_SIDEVIEW_SOLID_DAMAGE) && get_qr(qr_NOSOLIDDAMAGECOMBOS)) return false; //no point checking if both of these rules are on
21002
21003
2/4
✓ Branch 0 taken 13979847 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13979847 times.
13979847 if(z!=0||fakez!=0) return false;
21004 13979847 int32_t bx = x.getInt();
21005 13979847 int32_t by = y.getInt();
21006 13979847 int32_t initk = 0;
21007
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3451844 times.
✓ Branch 2 taken 2804743 times.
✓ Branch 3 taken 3735935 times.
✓ Branch 4 taken 3987325 times.
13979847 switch(dir)
21008 {
21009 case up:
21010
21011
2/2
✓ Branch 0 taken 83482 times.
✓ Branch 1 taken 3368362 times.
3451844 by-=get_qr(qr_NEW_HERO_MOVEMENT2)?(bigHitbox ? 4 : -4):(bigHitbox ? 1 : -7);
21012
2/2
✓ Branch 0 taken 83482 times.
✓ Branch 1 taken 3368362 times.
3451844 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) bx += 8;
21013
1/2
✓ Branch 0 taken 3368362 times.
✗ Branch 1 not taken.
3368362 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) bx += 4;
21014
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 3451744 times.
3451844 if(by<0)
21015 {
21016 100 return false;
21017 }
21018 3451744 break;
21019
21020 case down:
21021
21022 2804743 by+=get_qr(qr_NEW_HERO_MOVEMENT2)?16:20;
21023
2/2
✓ Branch 0 taken 89712 times.
✓ Branch 1 taken 2715031 times.
2804743 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) bx += 8;
21024
1/2
✓ Branch 0 taken 2715031 times.
✗ Branch 1 not taken.
2715031 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) bx += 4;
21025
2/2
✓ Branch 0 taken 26492 times.
✓ Branch 1 taken 2778251 times.
2804743 if(by>175)
21026 {
21027 26492 return false;
21028 }
21029
21030 2778251 break;
21031
21032 case left:
21033 3735935 bx-=get_qr(qr_NEW_HERO_MOVEMENT2)?1:4;
21034
2/2
✓ Branch 0 taken 119761 times.
✓ Branch 1 taken 3616174 times.
3735935 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) by += bigHitbox?7:11;
21035
1/2
✓ Branch 0 taken 3616174 times.
✗ Branch 1 not taken.
3616174 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) by += 4;
21036
4/4
✓ Branch 0 taken 3667723 times.
✓ Branch 1 taken 68212 times.
✓ Branch 2 taken 119761 times.
✓ Branch 3 taken 3547962 times.
3735935 if (!bigHitbox && !get_qr(qr_LENIENT_SOLID_DAMAGE))
21037 {
21038 3547962 by+=8;
21039 3547962 initk = 1;
21040 3547962 }
21041
2/2
✓ Branch 0 taken 20307 times.
✓ Branch 1 taken 3715628 times.
3735935 if(bx<0)
21042 {
21043 20307 return false;
21044 }
21045
21046 3715628 break;
21047
21048 case right:
21049 3987325 bx+=get_qr(qr_NEW_HERO_MOVEMENT2)?16:20;
21050
2/2
✓ Branch 0 taken 118008 times.
✓ Branch 1 taken 3869317 times.
3987325 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) by += bigHitbox?7:11;
21051
1/2
✓ Branch 0 taken 3869317 times.
✗ Branch 1 not taken.
3869317 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) by += 4;
21052
4/4
✓ Branch 0 taken 3909731 times.
✓ Branch 1 taken 77594 times.
✓ Branch 2 taken 118008 times.
✓ Branch 3 taken 3791723 times.
3987325 if (!bigHitbox && !get_qr(qr_LENIENT_SOLID_DAMAGE))
21053 {
21054 3791723 by+=8;
21055 3791723 initk = 1;
21056 3791723 }
21057
2/2
✓ Branch 0 taken 28669 times.
✓ Branch 1 taken 3958656 times.
3987325 if(bx>255)
21058 {
21059 28669 return false;
21060 }
21061
21062 3958656 break;
21063 }
21064
2/2
✓ Branch 0 taken 13493606 times.
✓ Branch 1 taken 410673 times.
13904279 if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) initk++;
21065 13904279 newcombo const& cmb = combobuf[MAPCOMBO(bx,by)];
21066 13904279 int32_t t = cmb.type;
21067
2/2
✓ Branch 0 taken 13904163 times.
✓ Branch 1 taken 116 times.
13904279 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
21068 116 t = cNONE;
21069 13904279 int32_t initbx = bx;
21070 13904279 int32_t initby = by;
21071
21072 // Unlike push blocks, damage combos should be tested on layers 2 and under
21073
2/2
✓ Branch 0 taken 25253545 times.
✓ Branch 1 taken 13904264 times.
39157809 for(int32_t i=(get_qr(qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
21074 {
21075 25253545 bx = initbx;
21076 25253545 by = initby;
21077
2/2
✓ Branch 0 taken 7734053 times.
✓ Branch 1 taken 17519492 times.
25253545 if (!get_qr(qr_NOSOLIDDAMAGECOMBOS))
21078 {
21079
2/2
✓ Branch 0 taken 16287465 times.
✓ Branch 1 taken 41506769 times.
57794234 for (int32_t k = initk; k <= 2; k++)
21080 {
21081 41506769 newcombo const& cmb = combobuf[FFCore.tempScreens[i]->data[COMBOPOS(bx,by)]];
21082 41506769 t = cmb.type;
21083
2/2
✓ Branch 0 taken 41506451 times.
✓ Branch 1 taken 318 times.
41506769 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
21084 318 t = cNONE;
21085 // Solid damage combos use pushing>0, hence the code is here.
21086
9/10
✓ Branch 0 taken 1869351 times.
✓ Branch 1 taken 39637418 times.
✓ Branch 2 taken 80484 times.
✓ Branch 3 taken 1788867 times.
✓ Branch 4 taken 77595 times.
✓ Branch 5 taken 2889 times.
✓ Branch 6 taken 1593 times.
✓ Branch 7 taken 76002 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1593 times.
41506769 if (!get_qr(qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
21087 {
21088
13/16
✓ Branch 0 taken 41473966 times.
✓ Branch 1 taken 28321 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28321 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28321 times.
✓ Branch 6 taken 1265 times.
✓ Branch 7 taken 27056 times.
✓ Branch 8 taken 169 times.
✓ Branch 9 taken 1096 times.
✓ Branch 10 taken 67 times.
✓ Branch 11 taken 102 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 67 times.
✓ Branch 14 taken 41502220 times.
✓ Branch 15 taken 67 times.
41502287 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,SWITCHBLOCK_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting)
21089 {
21090 // Bite Hero
21091
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 8 times.
67 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
21092 59 }
21093 41502279 }
21094
2/2
✓ Branch 0 taken 22313801 times.
✓ Branch 1 taken 19192960 times.
41506761 if (dir < left) bx += (k % 2) ? 7 : 8;
21095 19192960 else by += (k % 2) ? 7 : 8;
21096
2/2
✓ Branch 0 taken 40274742 times.
✓ Branch 1 taken 1232019 times.
41506761 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) break;
21097 40274742 }
21098 17519484 }
21099
4/6
✓ Branch 0 taken 383790 times.
✓ Branch 1 taken 24869747 times.
✓ Branch 2 taken 383790 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 356865 times.
25610402 if(isSideViewHero() && !get_qr(qr_NO_SIDEVIEW_SOLID_DAMAGE) && // Check for sideview damage combos
21100
3/4
✓ Branch 0 taken 356865 times.
✓ Branch 1 taken 26925 times.
✓ Branch 2 taken 356865 times.
✗ Branch 3 not taken.
383790 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
21101 {
21102
2/2
✓ Branch 0 taken 37353 times.
✓ Branch 1 taken 319512 times.
356865 if (get_qr(qr_LESS_AWFUL_SIDESPIKES))
21103 {
21104
2/6
✓ Branch 0 taken 37353 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37353 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37353 if (on_sideview_solid_oldpos(this) && (!getOnSideviewLadder() || DrunkDown()))
21105 {
21106
4/4
✓ Branch 0 taken 37349 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 37351 times.
✓ Branch 3 taken 2 times.
37353 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
21107 {
21108
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
21109 }
21110 37351 }
21111
1/2
✓ Branch 0 taken 37351 times.
✗ Branch 1 not taken.
37351 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
21112 37351 }
21113 else
21114 {
21115 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
21116
1/2
✓ Branch 0 taken 319512 times.
✗ Branch 1 not taken.
319512 if ( get_qr(qr_OLDSIDEVIEWSPIKES ) )
21117 {
21118
2/2
✓ Branch 0 taken 319507 times.
✓ Branch 1 taken 5 times.
639024 if (checkdamagecombos(x+8-(zfix)(tmpscr->csensitive),
21119
1/2
✓ Branch 0 taken 319512 times.
✗ Branch 1 not taken.
319512 x+8+(zc_max(tmpscr->csensitive-1,0)),
21120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 319512 times.
319512 y+17-(get_qr(qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2),
21121
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 319512 times.
✓ Branch 2 taken 319512 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 319512 times.
319512 y+17+zc_max((get_qr(qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2)-1,0), i-1, true))
21122 5 return true;
21123 319507 }
21124 else //2.50.1 and later
21125 {
21126 if(checkdamagecombos(x+4, x+12, y+16, y+24))
21127 return true;
21128 }
21129 }
21130
21131 356858 }
21132 25253530 }
21133 13904264 return false;
21134 13979847 }
21135 14140122 void HeroClass::checkpushblock()
21136 {
21137
2/2
✓ Branch 0 taken 14694 times.
✓ Branch 1 taken 14125428 times.
14140122 if(toogam) return;
21138
21139
3/4
✓ Branch 0 taken 14106788 times.
✓ Branch 1 taken 18640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14106788 times.
14125428 if(z!=0||fakez!=0) return;
21140
21141 // Return early in some cases..
21142 14106788 bool earlyReturn=false;
21143
21144
5/6
✓ Branch 0 taken 9721958 times.
✓ Branch 1 taken 4384830 times.
✓ Branch 2 taken 9721958 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10917689 times.
✓ Branch 5 taken 3189099 times.
14106788 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
21145
2/2
✓ Branch 0 taken 3855398 times.
✓ Branch 1 taken 7062291 times.
10917689 if(x.getInt()&15) earlyReturn=true;
21146
21147 // if(y<16) return;
21148
4/4
✓ Branch 0 taken 255615 times.
✓ Branch 1 taken 13851173 times.
✓ Branch 2 taken 128674 times.
✓ Branch 3 taken 126941 times.
14106788 if(isSideViewHero() && !on_sideview_solid_oldpos(this)) return;
21149
21150 13979847 int32_t bx = x.getInt()&0xF0;
21151 13979847 int32_t by = (y.getInt()&0xF0);
21152
21153
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3451844 times.
✓ Branch 2 taken 2804743 times.
✓ Branch 3 taken 3735935 times.
✓ Branch 4 taken 3987325 times.
13979847 switch(dir)
21154 {
21155 case up:
21156
2/2
✓ Branch 0 taken 118354 times.
✓ Branch 1 taken 3333490 times.
3451844 if(y<16)
21157 {
21158 118354 earlyReturn=true;
21159 118354 break;
21160 }
21161
21162
3/4
✓ Branch 0 taken 579889 times.
✓ Branch 1 taken 2753601 times.
✓ Branch 2 taken 579889 times.
✗ Branch 3 not taken.
3333490 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21163
21164
2/2
✓ Branch 0 taken 1930286 times.
✓ Branch 1 taken 1403204 times.
3333490 if((int32_t)x&8) bx+=16;
21165
21166 3333490 break;
21167
21168 case down:
21169
2/2
✓ Branch 0 taken 231798 times.
✓ Branch 1 taken 2572945 times.
2804743 if(y>128)
21170 {
21171 231798 earlyReturn=true;
21172 231798 break;
21173 }
21174 else
21175 {
21176 2572945 by+=16;
21177
21178
2/2
✓ Branch 0 taken 1650821 times.
✓ Branch 1 taken 922124 times.
2572945 if((int32_t)x&8) bx+=16;
21179 }
21180
21181 2572945 break;
21182
21183 case left:
21184
2/2
✓ Branch 0 taken 196528 times.
✓ Branch 1 taken 3539407 times.
3735935 if(x<32)
21185 {
21186 196528 earlyReturn=true;
21187 196528 break;
21188 }
21189 else
21190 {
21191 3539407 bx-=16;
21192
21193
2/2
✓ Branch 0 taken 2140934 times.
✓ Branch 1 taken 1398473 times.
3539407 if(y.getInt()&8)
21194 {
21195 1398473 by+=16;
21196 1398473 }
21197 }
21198
21199 3539407 break;
21200
21201 case right:
21202
2/2
✓ Branch 0 taken 205036 times.
✓ Branch 1 taken 3782289 times.
3987325 if(x>208)
21203 {
21204 205036 earlyReturn=true;
21205 205036 break;
21206 }
21207 else
21208 {
21209 3782289 bx+=16;
21210
21211
2/2
✓ Branch 0 taken 2304287 times.
✓ Branch 1 taken 1478002 times.
3782289 if(y.getInt()&8)
21212 {
21213 1478002 by+=16;
21214 1478002 }
21215 }
21216
21217 3782289 break;
21218 }
21219
21220
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13979832 times.
13979847 if (checksoliddamage()) return;
21221
21222
2/2
✓ Branch 0 taken 7363538 times.
✓ Branch 1 taken 6616294 times.
13979832 if(earlyReturn)
21223 7363538 return;
21224
21225 6616294 int itemid=current_item_id(itype_bracelet);
21226 6616294 size_t combopos = (by&0xF0)+(bx>>4);
21227
2/2
✓ Branch 0 taken 2760229 times.
✓ Branch 1 taken 3856065 times.
6616294 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & ITEM_FLAG1);
21228
2/2
✓ Branch 0 taken 3856065 times.
✓ Branch 1 taken 2760229 times.
6616294 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
21229
2/2
✓ Branch 0 taken 1712114 times.
✓ Branch 1 taken 10052135 times.
11764249 for(int lyr = 2; lyr > -1; --lyr) //Top-down, in case of stacked push blocks
21230 {
21231
4/4
✓ Branch 0 taken 6355213 times.
✓ Branch 1 taken 3696922 times.
✓ Branch 2 taken 1456491 times.
✓ Branch 3 taken 4898722 times.
10052135 if(get_qr(qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
21232
4/4
✓ Branch 0 taken 3435137 times.
✓ Branch 1 taken 1718276 times.
✓ Branch 2 taken 89477 times.
✓ Branch 3 taken 3345660 times.
5153413 if(lyr && !get_qr(qr_PUSHBLOCK_LAYER_1_2))
21233 3345660 continue;
21234 1807753 cpos_info& cpinfo = cpos_get(lyr, combopos);
21235 1807753 mapscr* m = FFCore.tempScreens[lyr];
21236
2/2
✓ Branch 0 taken 90213 times.
✓ Branch 1 taken 1717540 times.
1807753 int cid = lyr == 0 ? MAPCOMBO(bx,by) : MAPCOMBOL(lyr,bx,by);
21237 1807753 newcombo const& cmb = combobuf[cid];
21238 1807753 int f = MAPFLAG2(lyr-1,bx,by);
21239 1807753 int f2 = cmb.flag;
21240 1807753 int t = cmb.type;
21241
21242
6/6
✓ Branch 0 taken 1692151 times.
✓ Branch 1 taken 115602 times.
✓ Branch 2 taken 1687618 times.
✓ Branch 3 taken 4533 times.
✓ Branch 4 taken 2464 times.
✓ Branch 5 taken 1685154 times.
3492907 bool waitblock = (t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) ||
21243
2/2
✓ Branch 0 taken 1684292 times.
✓ Branch 1 taken 862 times.
1685154 (t == cPUSHBLOCK && (cmb.usrflags&cflag6));
21244 1807753 int heavy = 0;
21245
4/4
✓ Branch 0 taken 1802484 times.
✓ Branch 1 taken 5269 times.
✓ Branch 2 taken 15029 times.
✓ Branch 3 taken 1787455 times.
1807753 if(t==cPUSH_HW || t==cPUSH_HEAVY)
21246 20298 heavy = 1;
21247
4/4
✓ Branch 0 taken 1783558 times.
✓ Branch 1 taken 3897 times.
✓ Branch 2 taken 2464 times.
✓ Branch 3 taken 1781094 times.
1787455 else if(t==cPUSH_HEAVY2 || t==cPUSH_HW2)
21248 6361 heavy = 2;
21249
2/2
✓ Branch 0 taken 1780232 times.
✓ Branch 1 taken 862 times.
1781094 else if(t == cPUSHBLOCK)
21250 862 heavy = cmb.attribytes[0];
21251
21252
6/6
✓ Branch 0 taken 121863 times.
✓ Branch 1 taken 1685890 times.
✓ Branch 2 taken 39413 times.
✓ Branch 3 taken 82450 times.
✓ Branch 4 taken 3708 times.
✓ Branch 5 taken 35705 times.
1807753 if(waitblock && (pushing<16 || hasMainGuy())) continue;
21253
21254
8/8
✓ Branch 0 taken 1700136 times.
✓ Branch 1 taken 21459 times.
✓ Branch 2 taken 18606 times.
✓ Branch 3 taken 2853 times.
✓ Branch 4 taken 3028 times.
✓ Branch 5 taken 15578 times.
✓ Branch 6 taken 6256 times.
✓ Branch 7 taken 1715339 times.
1758632 if(heavy && (itemid<0 || glove->power < heavy ||
21255
3/4
✓ Branch 0 taken 12678 times.
✓ Branch 1 taken 2900 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2900 times.
21834 (limitedpush && usecounts[itemid] >= zc_max(1, glove->misc3)))) continue;
21256
21257 1715339 bool doit=false;
21258 1715339 bool changecombo=false;
21259
21260 1715339 int blockdir = dir;
21261
1/2
✓ Branch 0 taken 1715339 times.
✗ Branch 1 not taken.
1715339 if(blockdir > 3) blockdir = Y_DIR(dir);
21262
6/6
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 1714477 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 83 times.
✓ Branch 4 taken 476 times.
✓ Branch 5 taken 303 times.
1715339 if(t == cPUSHBLOCK && (get_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING) || (f!=mfPUSHED)))
21263 {
21264
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 181 times.
✓ Branch 3 taken 191 times.
✓ Branch 4 taken 123 times.
559 switch(blockdir)
21265 {
21266 case up:
21267 64 doit = cmb.usrflags & cflag1;
21268 64 break;
21269 case down:
21270 181 doit = cmb.usrflags & cflag2;
21271 181 break;
21272 case left:
21273 191 doit = cmb.usrflags & cflag3;
21274 191 break;
21275 case right:
21276 123 doit = cmb.usrflags & cflag4;
21277 123 break;
21278 }
21279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(cmb.usrflags & cflag5) //Separate directions
21280 {
21281 if(int limit = cmb.attribytes[4+blockdir])
21282 {
21283 if(cpinfo.pushes[blockdir] >= limit)
21284 doit = false;
21285 }
21286 else if(cmb.usrflags & cflag9)
21287 doit = false;
21288 }
21289 else
21290 {
21291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(int limit = cmb.attribytes[4])
21292 {
21293 if(cpinfo.sumpush() >= limit)
21294 doit = false;
21295 }
21296
1/2
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
559 else if(cmb.usrflags & cflag9)
21297 doit = false;
21298 }
21299 559 }
21300 else
21301 {
21302
2/2
✓ Branch 0 taken 1706336 times.
✓ Branch 1 taken 8444 times.
1714780 if(is_push_flag(f,dir))
21303 {
21304 8444 doit=true;
21305 8444 }
21306
21307
7/8
✓ Branch 0 taken 1714044 times.
✓ Branch 1 taken 736 times.
✓ Branch 2 taken 1714044 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✓ Branch 5 taken 1714320 times.
✓ Branch 6 taken 1713525 times.
✓ Branch 7 taken 519 times.
3428364 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
21308
3/4
✓ Branch 0 taken 1714032 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 1714032 times.
✗ Branch 3 not taken.
1714320 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
21309
3/4
✓ Branch 0 taken 1714032 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 1714032 times.
✗ Branch 3 not taken.
1714320 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
21310
3/4
✓ Branch 0 taken 1713718 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 1713718 times.
✗ Branch 3 not taken.
1713764 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
21311
3/4
✓ Branch 0 taken 1713663 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 1713663 times.
✗ Branch 3 not taken.
1713730 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
21312
3/4
✓ Branch 0 taken 1713657 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 1713657 times.
✗ Branch 3 not taken.
1713730 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
21313
2/2
✓ Branch 0 taken 1713330 times.
✓ Branch 1 taken 254 times.
1714044 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
21314 {
21315 519 changecombo=true;
21316 519 doit=true;
21317 519 }
21318 }
21319
21320
2/2
✓ Branch 0 taken 881498 times.
✓ Branch 1 taken 833105 times.
1714603 if(get_qr(qr_SOLIDBLK))
21321 {
21322
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 242490 times.
✓ Branch 2 taken 202955 times.
✓ Branch 3 taken 169360 times.
✓ Branch 4 taken 218300 times.
833105 switch(blockdir)
21323 {
21324 case up:
21325
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 242490 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 242490 times.
✓ Branch 4 taken 144600 times.
✓ Branch 5 taken 97890 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 97890 times.
✓ Branch 8 taken 144608 times.
✓ Branch 9 taken 97882 times.
242490 if(_walkflag(bx,by-8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)) doit=false;
21326
21327 242490 break;
21328
21329 case down:
21330
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 202955 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202955 times.
✓ Branch 4 taken 111329 times.
✓ Branch 5 taken 91626 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 91626 times.
✓ Branch 8 taken 111339 times.
✓ Branch 9 taken 91616 times.
202955 if(_walkflag(bx,by+24,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)) doit=false;
21331
21332 202955 break;
21333
21334 case left:
21335
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 169360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 169360 times.
✓ Branch 4 taken 76030 times.
✓ Branch 5 taken 93330 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 93330 times.
✓ Branch 8 taken 76046 times.
✓ Branch 9 taken 93314 times.
169360 if(_walkflag(bx-16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)) doit=false;
21336
21337 169360 break;
21338
21339 case right:
21340
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 218300 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 218300 times.
✓ Branch 4 taken 99244 times.
✓ Branch 5 taken 119056 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 119056 times.
✓ Branch 8 taken 99291 times.
✓ Branch 9 taken 119009 times.
218300 if(_walkflag(bx+16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)) doit=false;
21341
21342 218300 break;
21343 }
21344 833105 }
21345
21346
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 607813 times.
✓ Branch 2 taken 501216 times.
✓ Branch 3 taken 275920 times.
✓ Branch 4 taken 329654 times.
1714603 switch(blockdir)
21347 {
21348 case up:
21349
4/4
✓ Branch 0 taken 606573 times.
✓ Branch 1 taken 1240 times.
✓ Branch 2 taken 340 times.
✓ Branch 3 taken 606233 times.
607813 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
21350
21351 607813 break;
21352
21353 case down:
21354
4/4
✓ Branch 0 taken 499976 times.
✓ Branch 1 taken 1240 times.
✓ Branch 2 taken 378 times.
✓ Branch 3 taken 499598 times.
501216 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
21355
21356 501216 break;
21357
21358 case left:
21359
4/4
✓ Branch 0 taken 275044 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 274834 times.
275920 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
21360
21361 275920 break;
21362
21363 case right:
21364
4/4
✓ Branch 0 taken 328310 times.
✓ Branch 1 taken 1344 times.
✓ Branch 2 taken 377 times.
✓ Branch 3 taken 327933 times.
329654 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
21365
21366 329654 break;
21367 }
21368
21369
2/2
✓ Branch 0 taken 1709881 times.
✓ Branch 1 taken 4722 times.
1714603 if(doit)
21370 {
21371
2/2
✓ Branch 0 taken 4669 times.
✓ Branch 1 taken 53 times.
4722 if(limitedpush)
21372 53 ++usecounts[itemid];
21373
21374 // for(int32_t i=0; i<1; i++)
21375
2/2
✓ Branch 0 taken 657 times.
✓ Branch 1 taken 4065 times.
4722 if(!mblock2.active())
21376 {
21377
2/2
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 3602 times.
4065 if(is_push_flag(f,dir))
21378 {
21379 3602 m->sflag[combopos]=0;
21380 3602 }
21381
21382 4065 mblock2.blockLayer = lyr;
21383
21384
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 3860 times.
4065 if(t == cPUSHBLOCK)
21385 {
21386 205 zfix blockstep = 0.5;
21387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(cmb.attrishorts[0] > 0)
21388 205 blockstep = zslongToFix(cmb.attrishorts[0]*100);
21389 205 mblock2.push_new(zfix(bx),zfix(by),blockdir,f,blockstep);
21390 205 mblock2.blockinfo = cpinfo;
21391 205 mblock2.blockinfo.push(blockdir, cmb.usrflags&cflag8);
21392 205 cpinfo.clearInfo();
21393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(cmb.attribytes[1])
21394 205 sfx(cmb.attribytes[1],(int32_t)x);
21395 205 }
21396 else
21397 {
21398 3860 mblock2.push((zfix)bx,(zfix)by,blockdir,f);
21399
21400
2/2
✓ Branch 0 taken 1052 times.
✓ Branch 1 taken 2808 times.
3860 if(get_qr(qr_MORESOUNDS))
21401 1052 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
21402 }
21403 4065 }
21404 4722 break;
21405 }
21406 1709881 }
21407 14139386 }
21408
21409 847 bool usekey()
21410 {
21411 847 int32_t itemid = current_item_id(itype_magickey);
21412
21413
3/4
✓ Branch 0 taken 787 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
847 if(itemid<0 ||
21414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
21415 : itemsbuf[itemid].power!=dlevel))
21416 {
21417
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 668 times.
787 if(game->lvlkeys[dlevel]!=0)
21418 {
21419 119 game->lvlkeys[dlevel]--;
21420 //run script for level key item
21421 119 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
21422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9065 times.
9065 for ( int32_t q = 0; q < MAXITEMS; ++q )
21423 {
21424
2/2
✓ Branch 0 taken 8946 times.
✓ Branch 1 taken 119 times.
9065 if ( itemsbuf[q].family == itype_lkey )
21425 {
21426 119 key_item = q; break;
21427 }
21428 8946 }
21429
21430
2/8
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
119 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21431 {
21432 int i = key_item;
21433 FFCore.reset_script_engine_data(ScriptType::Item, i);
21434 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21435 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21436 }
21437 119 return true;
21438 }
21439 else
21440 {
21441
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 332 times.
668 if(game->get_keys()==0)
21442 {
21443 332 return false;
21444 }
21445 else
21446 {
21447 //run script for key item
21448 336 int32_t key_item = 0; //current_item_id(itype_key); //not possible
21449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 for ( int32_t q = 0; q < MAXITEMS; ++q )
21450 {
21451
2/2
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 336 times.
3360 if ( itemsbuf[q].family == itype_key )
21452 {
21453 336 key_item = q; break;
21454 }
21455 3024 }
21456 //zprint2("key_item is: %d\n",key_item);
21457 //zprint2("key_item script is: %d\n",itemsbuf[key_item].script);
21458
2/8
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 336 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
336 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21459 {
21460 int i = key_item;
21461 FFCore.reset_script_engine_data(ScriptType::Item, i);
21462 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21463 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21464 }
21465 336 game->change_keys(-1);
21466 }
21467 }
21468 336 }
21469
21470 396 return true;
21471 847 }
21472
21473 11 bool canUseKey(int32_t num)
21474 {
21475 11 int32_t itemid = current_item_id(itype_magickey);
21476
21477
1/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(itemid<0 ||
21478 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
21479 : itemsbuf[itemid].power!=dlevel))
21480 {
21481 11 return game->lvlkeys[dlevel] + game->get_keys() >= num;
21482 }
21483
21484 return true;
21485 11 }
21486
21487 11 bool usekey(int32_t num)
21488 {
21489
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
11 if(!canUseKey(num)) return false;
21490
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 for(auto q = 0; q < num; ++q)
21491 {
21492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!usekey()) return false; //should never return false here, but, just to be safe....
21493 8 }
21494 8 return true;
21495 11 }
21496
21497
21498 4075 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
21499 {
21500 4075 int32_t mc = (y&0xF0)+(x>>4);
21501
5/6
✓ Branch 0 taken 4046 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 4046 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3366 times.
✓ Branch 5 taken 680 times.
8150 bool ret = (((mc==7||mc==8||mc==23||mc==24) && tmpscr->door[up]==lock)
21502
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4075 times.
✓ Branch 2 taken 4066 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 4066 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4066 times.
✗ Branch 7 not taken.
4075 || ((mc==151||mc==152||mc==167||mc==168) && tmpscr->door[down]==lock)
21503
3/6
✓ Branch 0 taken 4075 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4075 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4075 times.
✗ Branch 5 not taken.
4075 || ((mc==64||mc==65||mc==80||mc==81) && tmpscr->door[left]==lock)
21504
6/8
✓ Branch 0 taken 4063 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4063 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3865 times.
✓ Branch 5 taken 198 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3865 times.
4075 || ((mc==78||mc==79||mc==94||mc==95) && tmpscr->door[right]==lock));
21505 4075 return ret;
21506 }
21507
21508 13573217 void HeroClass::oldchecklockblock()
21509 {
21510
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 13558862 times.
13573217 if(toogam) return;
21511
21512 13558862 int32_t bx = x.getInt()&0xF0;
21513 13558862 int32_t bx2 = int32_t(x+8)&0xF0;
21514 13558862 int32_t by = y.getInt()&0xF0;
21515
21516
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3353800 times.
✓ Branch 2 taken 2692329 times.
✓ Branch 3 taken 3627793 times.
✓ Branch 4 taken 3884940 times.
13558862 switch(dir)
21517 {
21518 case up:
21519
4/4
✓ Branch 0 taken 581190 times.
✓ Branch 1 taken 2772610 times.
✓ Branch 2 taken 11795 times.
✓ Branch 3 taken 569395 times.
3353800 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21520
21521 3353800 break;
21522
21523 case down:
21524 2692329 by+=16;
21525 2692329 break;
21526
21527 case left:
21528
2/2
✓ Branch 0 taken 1601886 times.
✓ Branch 1 taken 2025907 times.
3627793 if((((int32_t)x)&0x0F)<8)
21529 2025907 bx-=16;
21530
21531
2/2
✓ Branch 0 taken 2222872 times.
✓ Branch 1 taken 1404921 times.
3627793 if(y.getInt()&8)
21532 {
21533 1404921 by+=16;
21534 1404921 }
21535
21536 3627793 bx2=bx;
21537 3627793 break;
21538
21539 case right:
21540 3884940 bx+=16;
21541
21542
2/2
✓ Branch 0 taken 2390117 times.
✓ Branch 1 taken 1494823 times.
3884940 if(y.getInt()&8)
21543 {
21544 1494823 by+=16;
21545 1494823 }
21546
21547 3884940 bx2=bx;
21548 3884940 break;
21549 }
21550
21551 13558862 bool found1=false;
21552 13558862 bool found2=false;
21553 13558862 int32_t foundlayer = -1;
21554 13558862 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
21555 13558862 newcombo const& cmb = combobuf[cid1];
21556 13558862 newcombo const& cmb2 = combobuf[cid2];
21557 // Layer 0 is overridden by Locked Doors
21558
5/8
✓ Branch 0 taken 2512 times.
✓ Branch 1 taken 13556350 times.
✓ Branch 2 taken 2512 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2512 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2512 times.
13558862 if((cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1) && !islockeddoor(bx,by,dLOCKED)))
21559 {
21560 2512 found1=true;
21561 2512 foundlayer = 0;
21562 2512 }
21563
5/8
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 13556145 times.
✓ Branch 2 taken 205 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 205 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 205 times.
13556350 else if (cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1) && !islockeddoor(bx2,by,dLOCKED))
21564 {
21565 205 found2=true;
21566 205 foundlayer = 0;
21567 205 }
21568
21569
2/2
✓ Branch 0 taken 27117724 times.
✓ Branch 1 taken 13558862 times.
40676586 for (int32_t i = 0; i <= 1; ++i)
21570 {
21571
2/2
✓ Branch 0 taken 20037825 times.
✓ Branch 1 taken 7079899 times.
27117724 if(tmpscr2[i].valid!=0)
21572 {
21573
2/2
✓ Branch 0 taken 6719162 times.
✓ Branch 1 taken 360737 times.
7079899 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21574 {
21575
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6719162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6719162 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
21576
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6719162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6719162 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
21577 6719162 }
21578 else
21579 {
21580
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 359372 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
360737 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
21581
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 359372 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
360737 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
21582 }
21583 7079899 }
21584 27117724 }
21585
21586
21587 // Layers
21588
4/4
✓ Branch 0 taken 13556350 times.
✓ Branch 1 taken 2512 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 13556145 times.
13558862 if(!(found1 || found2))
21589 {
21590 13556145 foundlayer = -1;
21591
2/2
✓ Branch 0 taken 13556060 times.
✓ Branch 1 taken 27112256 times.
40668316 for(int32_t i=0; i<2; i++)
21592 {
21593 27112256 cid1 = MAPCOMBO2(i, bx, by);
21594 27112256 cid2 = MAPCOMBO2(i, bx2, by);
21595 27112256 newcombo const& cmb = combobuf[cid1];
21596 27112256 newcombo const& cmb2 = combobuf[cid2];
21597
2/2
✓ Branch 0 taken 13556111 times.
✓ Branch 1 taken 13556145 times.
27112256 if (i == 0)
21598 {
21599
2/2
✓ Branch 0 taken 11677309 times.
✓ Branch 1 taken 1878836 times.
13556145 if(tmpscr2[1].valid!=0)
21600 {
21601
2/2
✓ Branch 0 taken 1756772 times.
✓ Branch 1 taken 122064 times.
1878836 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21602 {
21603
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1756772 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1756772 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue; //Continue, because It didn't find any on layer 0, and if you're checking
21604
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1756772 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1756772 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
21605 1756772 }
21606 else
21607 {
21608
3/4
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 121612 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 452 times.
122064 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
21609
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 121612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
121612 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
21610 }
21611 1878384 }
21612 13555693 }
21613
4/6
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 27111722 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 82 times.
27111804 if(cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
21614 {
21615 82 found1=true;
21616 82 foundlayer = i+1;
21617 //zprint("Found layer: %d \n", i);
21618 82 break;
21619 }
21620
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 27111719 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
27111722 else if(cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, i))
21621 {
21622 3 found2=true;
21623 3 foundlayer = i+1;
21624 //zprint("Found layer: %d \n", i);
21625 3 break;
21626 }
21627 27111719 }
21628 13556145 }
21629
21630
4/4
✓ Branch 0 taken 13556268 times.
✓ Branch 1 taken 2594 times.
✓ Branch 2 taken 13558462 times.
✓ Branch 3 taken 400 times.
13558862 if(!(found1 || found2) || pushing<8)
21631 {
21632 13558462 return;
21633 }
21634
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 51 times.
400 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
21635
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 262 times.
400 if(!try_locked_combo(cmb3))
21636 262 return;
21637
21638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(cmb.usrflags&cflag16)
21639 {
21640 setxmapflag(1<<cmb.attribytes[5]);
21641 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
21642 }
21643 else
21644 {
21645 138 setmapflag(mLOCKBLOCK);
21646 138 remove_lockblocks((currscr>=128)?1:0);
21647 }
21648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if ( cmb3.usrflags&cflag3 )
21649 {
21650 if ( (cmb3.attribytes[3]) )
21651 sfx(cmb3.attribytes[3]);
21652 }
21653 138 else sfx(WAV_DOOR);
21654 13573217 }
21655
21656 13573217 void HeroClass::oldcheckbosslockblock()
21657 {
21658
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 13558862 times.
13573217 if(toogam) return;
21659
21660 13558862 int32_t bx = x.getInt()&0xF0;
21661 13558862 int32_t bx2 = int32_t(x+8)&0xF0;
21662 13558862 int32_t by = y.getInt()&0xF0;
21663
21664
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3353800 times.
✓ Branch 2 taken 2692329 times.
✓ Branch 3 taken 3627793 times.
✓ Branch 4 taken 3884940 times.
13558862 switch(dir)
21665 {
21666 case up:
21667
4/4
✓ Branch 0 taken 581190 times.
✓ Branch 1 taken 2772610 times.
✓ Branch 2 taken 11795 times.
✓ Branch 3 taken 569395 times.
3353800 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21668
21669 3353800 break;
21670
21671 case down:
21672 2692329 by+=16;
21673 2692329 break;
21674
21675 case left:
21676
2/2
✓ Branch 0 taken 1601886 times.
✓ Branch 1 taken 2025907 times.
3627793 if((((int32_t)x)&0x0F)<8)
21677 2025907 bx-=16;
21678
21679
2/2
✓ Branch 0 taken 2222872 times.
✓ Branch 1 taken 1404921 times.
3627793 if(y.getInt()&8)
21680 {
21681 1404921 by+=16;
21682 1404921 }
21683
21684 3627793 bx2=bx;
21685 3627793 break;
21686
21687 case right:
21688 3884940 bx+=16;
21689
21690
2/2
✓ Branch 0 taken 2390117 times.
✓ Branch 1 taken 1494823 times.
3884940 if(y.getInt()&8)
21691 {
21692 1494823 by+=16;
21693 1494823 }
21694
21695 3884940 bx2=bx;
21696 3884940 break;
21697 }
21698
21699
21700 13558862 bool found1 = false;
21701 13558862 bool found2 = false;
21702 13558862 int32_t foundlayer = -1;
21703 13558862 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
21704 13558862 newcombo const& cmb = combobuf[cid1];
21705 13558862 newcombo const& cmb2 = combobuf[cid2];
21706 // Layer 0 is overridden by Locked Doors
21707
5/8
✓ Branch 0 taken 1327 times.
✓ Branch 1 taken 13557535 times.
✓ Branch 2 taken 1327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1327 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1327 times.
13558862 if ((cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, -1) && !islockeddoor(bx, by, dLOCKED)))
21708 {
21709 1327 found1 = true;
21710 1327 foundlayer = 0;
21711 1327 }
21712
5/8
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 13557504 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31 times.
13557535 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, -1) && !islockeddoor(bx2, by, dLOCKED))
21713 {
21714 31 found2 = true;
21715 31 foundlayer = 0;
21716 31 }
21717
21718
2/2
✓ Branch 0 taken 27117724 times.
✓ Branch 1 taken 13558862 times.
40676586 for (int32_t i = 0; i <= 1; ++i)
21719 {
21720
2/2
✓ Branch 0 taken 20037825 times.
✓ Branch 1 taken 7079899 times.
27117724 if (tmpscr2[i].valid != 0)
21721 {
21722
2/2
✓ Branch 0 taken 6719162 times.
✓ Branch 1 taken 360737 times.
7079899 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21723 {
21724
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6719162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6719162 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
21725
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6719162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6719162 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
21726 6719162 }
21727 else
21728 {
21729
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 359372 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
360737 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
21730
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 359372 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
360737 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
21731 }
21732 7079899 }
21733 27117724 }
21734
21735
21736 // Layers
21737
4/4
✓ Branch 0 taken 13557535 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 13557504 times.
13558862 if (!(found1 || found2))
21738 {
21739 13557504 foundlayer = -1;
21740
2/2
✓ Branch 0 taken 13557504 times.
✓ Branch 1 taken 27115008 times.
40672512 for (int32_t i = 0; i < 2; i++)
21741 {
21742 27115008 cid1 = MAPCOMBO2(i, bx, by);
21743 27115008 cid2 = MAPCOMBO2(i, bx2, by);
21744 27115008 newcombo const& cmb = combobuf[cid1];
21745 27115008 newcombo const& cmb2 = combobuf[cid2];
21746
2/2
✓ Branch 0 taken 13557504 times.
✓ Branch 1 taken 13557504 times.
27115008 if (i == 0)
21747 {
21748
2/2
✓ Branch 0 taken 11678316 times.
✓ Branch 1 taken 1879188 times.
13557504 if (tmpscr2[1].valid != 0)
21749 {
21750
2/2
✓ Branch 0 taken 1757060 times.
✓ Branch 1 taken 122128 times.
1879188 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21751 {
21752
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1757060 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1757060 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
21753
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1757060 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1757060 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
21754 1757060 }
21755 else
21756 {
21757
3/4
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 121676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 452 times.
122128 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
21758
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 121676 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
121676 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
21759 }
21760 1878736 }
21761 13557052 }
21762
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27114556 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27114556 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, i))
21763 {
21764 found1 = true;
21765 foundlayer = i;
21766 break;
21767 }
21768
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27114556 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27114556 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, i))
21769 {
21770 found2 = true;
21771 foundlayer = i;
21772 break;
21773 }
21774 27114556 }
21775 13557504 }
21776
21777
4/4
✓ Branch 0 taken 13557535 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 13558391 times.
✓ Branch 3 taken 471 times.
13558862 if (!(found1 || found2) || pushing < 8)
21778 {
21779 13558391 return;
21780 }
21781
2/2
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 3 times.
471 int32_t cid = found1 ? cid1 : cid2;
21782
21783
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 436 times.
471 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
21784
21785
21786 // Run Boss Key Script
21787 35 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2380 times.
2380 for ( int32_t q = 0; q < MAXITEMS; ++q )
21789 {
21790
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 35 times.
2380 if ( itemsbuf[q].family == itype_bosskey )
21791 {
21792 35 key_item = q; break;
21793 }
21794 2345 }
21795
2/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
35 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21796 {
21797 int i = key_item;
21798 FFCore.reset_script_engine_data(ScriptType::Item, i);
21799 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21800 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21801 }
21802
21803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(cmb.usrflags&cflag16)
21804 {
21805 setxmapflag(1<<cmb.attribytes[5]);
21806 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
21807 }
21808 else
21809 {
21810 35 setmapflag(mBOSSLOCKBLOCK);
21811 35 remove_bosslockblocks((currscr>=128)?1:0);
21812 }
21813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if ( (combobuf[cid].attribytes[3]) )
21814 35 sfx(combobuf[cid].attribytes[3]);
21815 13573217 }
21816
21817 39409596 void HeroClass::oldcheckchest(int32_t type)
21818 {
21819 // chests aren't affected by tmpscr->flags2&fAIRCOMBOS
21820
5/6
✓ Branch 0 taken 39369378 times.
✓ Branch 1 taken 40218 times.
✓ Branch 2 taken 39328629 times.
✓ Branch 3 taken 40749 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 39328629 times.
39409596 if(toogam || z>0 || fakez > 0) return;
21821
2/2
✓ Branch 0 taken 37726428 times.
✓ Branch 1 taken 1602201 times.
39328629 if(pushing<8) return;
21822 1602201 int32_t bx = x.getInt()&0xF0;
21823 1602201 int32_t bx2 = int32_t(x+8)&0xF0;
21824 1602201 int32_t by = y.getInt()&0xF0;
21825
21826
3/4
✓ Branch 0 taken 867594 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 339711 times.
✓ Branch 3 taken 394896 times.
1602201 switch(dir)
21827 {
21828 case up:
21829
2/2
✓ Branch 0 taken 40752 times.
✓ Branch 1 taken 354144 times.
394896 if(isSideViewHero()) return;
21830
21831
4/4
✓ Branch 0 taken 81006 times.
✓ Branch 1 taken 273138 times.
✓ Branch 2 taken 78609 times.
✓ Branch 3 taken 2397 times.
354144 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21832
21833 354144 break;
21834
21835 case left:
21836 case right:
21837
2/2
✓ Branch 0 taken 16173 times.
✓ Branch 1 taken 851421 times.
867594 if(isSideViewHero()) break;
21838 [[fallthrough]];
21839 case down:
21840 1191132 return;
21841 }
21842
21843 370317 bool found=false;
21844 370317 bool itemflag=false;
21845
21846
3/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 370180 times.
✓ Branch 2 taken 137 times.
✗ Branch 3 not taken.
370352 if((combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))||
21847
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 370145 times.
370180 (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1)))
21848 {
21849 172 found=true;
21850 172 }
21851
2/2
✓ Branch 0 taken 740634 times.
✓ Branch 1 taken 370317 times.
1110951 for (int32_t i = 0; i <= 1; ++i)
21852 {
21853
2/2
✓ Branch 0 taken 571716 times.
✓ Branch 1 taken 168918 times.
740634 if(tmpscr2[i].valid!=0)
21854 {
21855
2/2
✓ Branch 0 taken 168057 times.
✓ Branch 1 taken 861 times.
168918 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21856 {
21857
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 168057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
168057 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
21858
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 168057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
168057 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
21859 168057 }
21860 else
21861 {
21862
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
21863
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
21864 }
21865 168918 }
21866 740634 }
21867
21868
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 370145 times.
370317 if(!found)
21869 {
21870
2/2
✓ Branch 0 taken 370145 times.
✓ Branch 1 taken 740290 times.
1110435 for(int32_t i=0; i<2; i++)
21871 {
21872
2/2
✓ Branch 0 taken 370145 times.
✓ Branch 1 taken 370145 times.
740290 if (i == 0)
21873 {
21874
2/2
✓ Branch 0 taken 335356 times.
✓ Branch 1 taken 34789 times.
370145 if(tmpscr2[1].valid!=0)
21875 {
21876
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 381 times.
34789 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21877 {
21878
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34408 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
21879
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34408 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
21880 34408 }
21881 else
21882 {
21883
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
21884
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
21885 }
21886 34789 }
21887 370145 }
21888
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 740290 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
740290 if((combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))||
21889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 740290 times.
740290 (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i)))
21890 {
21891 found=true;
21892 break;
21893 }
21894 740290 }
21895 370145 }
21896
21897
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 370145 times.
370317 if(!found)
21898 {
21899 370145 return;
21900 }
21901
21902
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 2 times.
172 switch(type)
21903 {
21904 case cLOCKEDCHEST:
21905
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 56 times.
69 if(!usekey()) return;
21906
21907 13 setmapflag(mLOCKEDCHEST);
21908 13 break;
21909
21910 case cCHEST:
21911 101 setmapflag(mCHEST);
21912 101 break;
21913
21914 case cBOSSCHEST:
21915
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
21916 // Run Boss Key Script
21917 2 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 for ( int32_t q = 0; q < MAXITEMS; ++q )
21919 {
21920
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 2 times.
136 if ( itemsbuf[q].family == itype_bosskey )
21921 {
21922 2 key_item = q; break;
21923 }
21924 134 }
21925
2/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21926 {
21927 int i = key_item;
21928 FFCore.reset_script_engine_data(ScriptType::Item, i);
21929 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21930 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21931 }
21932 2 setmapflag(mBOSSCHEST);
21933 2 break;
21934 }
21935
21936 116 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
21937 116 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
21938 116 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
21939 116 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
21940 116 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
21941 116 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
21942
21943
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!itemflag)
21944 {
21945 for(int32_t i=0; i<2; i++)
21946 {
21947 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
21948 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
21949 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
21950 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
21951 }
21952 }
21953
21954
3/6
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
116 if(itemflag && !getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
21955 {
21956
4/8
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 items.add(new item(x, y,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
21957 116 }
21958 39409596 }
21959
21960 4143916 void HeroClass::checkchest(int32_t type)
21961 {
21962
4/4
✓ Branch 0 taken 3140466 times.
✓ Branch 1 taken 1003450 times.
✓ Branch 2 taken 1003450 times.
✓ Branch 3 taken 2137016 times.
4143916 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
21963
2/2
✓ Branch 0 taken 566783 times.
✓ Branch 1 taken 3577133 times.
4143916 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
21964
2/2
✓ Branch 0 taken 566783 times.
✓ Branch 1 taken 3577133 times.
4143916 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
21965
2/2
✓ Branch 0 taken 566783 times.
✓ Branch 1 taken 3577133 times.
4143916 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
21966
2/2
✓ Branch 0 taken 1133566 times.
✓ Branch 1 taken 3010350 times.
4143916 if(ischest)
21967 {
21968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3010350 times.
3010350 if(get_qr(qr_OLD_CHEST_COLLISION))
21969 {
21970 oldcheckchest(type);
21971 return;
21972 }
21973 3010350 }
21974
3/4
✓ Branch 0 taken 1133566 times.
✓ Branch 1 taken 3010350 times.
✓ Branch 2 taken 1133566 times.
✗ Branch 3 not taken.
4143916 if(islockblock && get_qr(qr_OLD_LOCKBLOCK_COLLISION))
21975 {
21976 if(type == cLOCKBLOCK)
21977 oldchecklockblock();
21978 else if(type == cBOSSLOCKBLOCK)
21979 oldcheckbosslockblock();
21980 return;
21981 }
21982
5/6
✓ Branch 0 taken 4139374 times.
✓ Branch 1 taken 4542 times.
✓ Branch 2 taken 4117793 times.
✓ Branch 3 taken 21581 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4117793 times.
4143916 if(toogam || z>0 || fakez > 0) return;
21983 4117793 zfix bx, by;
21984 4117793 zfix bx2, by2;
21985 4117793 zfix fx(-1), fy(-1);
21986
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 894589 times.
✓ Branch 2 taken 913717 times.
✓ Branch 3 taken 1131460 times.
✓ Branch 4 taken 1178027 times.
4117793 switch(dir)
21987 {
21988 case up:
21989 894589 by = y + (bigHitbox ? -2 : 6);
21990 894589 by2 = by;
21991 894589 bx = x + 4;
21992 894589 bx2 = bx + 8;
21993 894589 break;
21994 case down:
21995 913717 by = y + 17;
21996 913717 by2 = by;
21997 913717 bx = x + 4;
21998 913717 bx2 = bx + 8;
21999 913717 break;
22000 case left:
22001 1131460 by = y + (bigHitbox ? 0 : 8);
22002 1131460 by2 = y + 8;
22003 1131460 bx = x - 2;
22004 1131460 bx2 = x - 2;
22005 1131460 break;
22006 case right:
22007 1178027 by = y + (bigHitbox ? 0 : 8);
22008 1178027 by2 = y + 8;
22009 1178027 bx = x + 17;
22010 1178027 bx2 = x + 17;
22011 1178027 break;
22012 }
22013
22014 4117793 int32_t found = -1;
22015 4117793 int32_t foundlayer = 0;
22016
22017 4117793 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
22018
22019
4/6
✓ Branch 0 taken 2434 times.
✓ Branch 1 taken 4115359 times.
✓ Branch 2 taken 2434 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2434 times.
4117793 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1))
22020 {
22021 2434 found = MAPCOMBO(bx,by);
22022 2434 fx = bx; fy = by;
22023
2/2
✓ Branch 0 taken 4868 times.
✓ Branch 1 taken 2434 times.
7302 for (int32_t i = 0; i <= 1; ++i)
22024 {
22025
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 3711 times.
4868 if(tmpscr2[i].valid!=0)
22026 {
22027
2/2
✓ Branch 0 taken 2714 times.
✓ Branch 1 taken 997 times.
3711 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22028 {
22029
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2714 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2714 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
22030 2714 }
22031 else
22032 {
22033
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 997 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
997 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
22034 }
22035 3711 }
22036 4868 }
22037 2434 }
22038
2/2
✓ Branch 0 taken 2434 times.
✓ Branch 1 taken 4115359 times.
4117793 if(found<0)
22039 {
22040 4115359 cmb = &combobuf[MAPCOMBO(bx2,by2)];
22041
4/6
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 4115283 times.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 76 times.
4115359 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, -1))
22042 {
22043 76 found = MAPCOMBO(bx2,by2);
22044
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 532 times.
608 for (int32_t i = 0; i <= 6; ++i)
22045 {
22046
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 212 times.
532 if(tmpscr2[i].valid!=0)
22047 {
22048
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 120 times.
212 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22049 {
22050
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
92 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i])))
22051 {
22052 found = -1;
22053 break;
22054 }
22055 92 }
22056 else
22057 {
22058
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i])))
22059 {
22060 found = -1;
22061 break;
22062 }
22063 }
22064 212 }
22065 532 }
22066
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(found != -1)
22067 {
22068 76 fx = bx2; fy = by2;
22069 76 }
22070 76 }
22071 4115359 }
22072
22073
2/2
✓ Branch 0 taken 2510 times.
✓ Branch 1 taken 4115283 times.
4117793 if(found<0)
22074 {
22075
2/2
✓ Branch 0 taken 4115084 times.
✓ Branch 1 taken 24690703 times.
28805787 for(int32_t i=0; i<6; i++)
22076 {
22077 24690703 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
22078
4/6
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 24690504 times.
✓ Branch 2 taken 199 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 199 times.
24690703 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
22079 {
22080 199 found = MAPCOMBO2(i,bx,by);
22081
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 995 times.
1194 for(int32_t j = i+1; j < 6; ++j)
22082 {
22083
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 245 times.
995 if (tmpscr2[j].valid!=0)
22084 {
22085
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 139 times.
245 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22086 {
22087
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
106 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[j])))
22088 {
22089 found = -1;
22090 break;
22091 }
22092 106 }
22093 else
22094 {
22095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[j])))
22096 {
22097 found = -1;
22098 break;
22099 }
22100 }
22101 245 }
22102 995 }
22103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199 times.
199 if(found>-1)
22104 {
22105 199 foundlayer = i+1;
22106 199 fx = bx; fy = by;
22107 199 break;
22108 }
22109 }
22110 24690504 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
22111
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24690504 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24690504 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, i))
22112 {
22113 found = MAPCOMBO2(i,bx2,by2);
22114 for(int32_t j = i+1; j < 6; ++j)
22115 {
22116 if (tmpscr2[j].valid!=0)
22117 {
22118 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22119 {
22120 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[j])))
22121 {
22122 found = -1;
22123 break;
22124 }
22125 }
22126 else
22127 {
22128 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[j])))
22129 {
22130 found = -1;
22131 break;
22132 }
22133 }
22134 }
22135 }
22136 if(found>-1)
22137 {
22138 foundlayer = i+1;
22139 fx = bx2; fy = by2;
22140 break;
22141 }
22142 }
22143 24690504 }
22144 4115283 }
22145
22146
2/2
✓ Branch 0 taken 2709 times.
✓ Branch 1 taken 4115084 times.
4117793 if(found<0) return;
22147 2709 cmb = &combobuf[found];
22148
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2531 times.
✓ Branch 2 taken 78 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 78 times.
2709 switch(dir)
22149 {
22150 case up:
22151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2531 times.
2531 if(cmb->usrflags&cflag10)
22152 return;
22153 2531 break;
22154 case down:
22155
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 9 times.
78 if(cmb->usrflags&cflag9)
22156 69 return;
22157 9 break;
22158 case left:
22159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(cmb->usrflags&cflag12)
22160 return;
22161 22 break;
22162 case right:
22163
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 17 times.
78 if(cmb->usrflags&cflag11)
22164 61 return;
22165 17 break;
22166 }
22167 2579 int32_t intbtn = cmb->attribytes[2];
22168
22169
2/2
✓ Branch 0 taken 2498 times.
✓ Branch 1 taken 81 times.
2579 if(intbtn) //
22170 {
22171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2498 times.
2498 if(cmb->usrflags & cflag13) //display prompt
22172 {
22173 2498 int altcmb = cmb->attributes[2]/10000;
22174 2498 prompt_combo = cmb->attributes[1]/10000;
22175
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2498 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2498 if(altcmb && ((islocked && !can_locked_combo(*cmb))
22176 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
22177 prompt_combo = altcmb;
22178 2498 prompt_cset = cmb->attribytes[4];
22179 2498 prompt_x = cmb->attrishorts[0];
22180 2498 prompt_y = cmb->attrishorts[1];
22181 2498 }
22182
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 2444 times.
2498 if(!getIntBtnInput(intbtn, true, true, false, false))
22183 {
22184 2444 return; //Button not pressed
22185 }
22186 54 }
22187
4/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 9 times.
81 else if(pushing < 8 || pushing % 8) return; //Not pushing against chest enough
22188
22189
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 21 times.
63 if(ischest)
22190 {
22191
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!trigger_chest(foundlayer, COMBOPOS(fx,fy))) return;
22192 42 }
22193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 else if(islockblock)
22194 {
22195
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 3 times.
21 if(!trigger_lockblock(foundlayer, COMBOPOS(fx,fy))) return;
22196 18 }
22197
3/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
60 if(intbtn && (cmb->usrflags & cflag13))
22198 51 prompt_combo = 0;
22199 4143916 }
22200
22201 14164265 void HeroClass::checkgenpush()
22202 {
22203 14164265 zfix bx, by;
22204 14164265 zfix bx2, by2;
22205
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3477403 times.
✓ Branch 2 taken 2819626 times.
✓ Branch 3 taken 3792779 times.
✓ Branch 4 taken 4074457 times.
14164265 switch(dir)
22206 {
22207 case up:
22208 3477403 by = y + (bigHitbox ? -2 : 6);
22209 3477403 by2 = by;
22210 3477403 bx = x + 4;
22211 3477403 bx2 = bx + 8;
22212 3477403 break;
22213 case down:
22214 2819626 by = y + 17;
22215 2819626 by2 = by;
22216 2819626 bx = x + 4;
22217 2819626 bx2 = bx + 8;
22218 2819626 break;
22219 case left:
22220 3792779 by = y + (bigHitbox ? 0 : 8);
22221 3792779 by2 = y + 8;
22222 3792779 bx = x - 2;
22223 3792779 bx2 = x - 2;
22224 3792779 break;
22225 case right:
22226 4074457 by = y + (bigHitbox ? 0 : 8);
22227 4074457 by2 = y + 8;
22228 4074457 bx = x + 17;
22229 4074457 bx2 = x + 17;
22230 4074457 break;
22231 }
22232 14164265 auto pos1 = COMBOPOS(bx,by);
22233 14164265 auto pos2 = COMBOPOS(bx2,by2);
22234
2/2
✓ Branch 0 taken 14164265 times.
✓ Branch 1 taken 99149855 times.
113314120 for(auto layer = 0; layer < 7; ++layer)
22235 {
22236 99149855 mapscr* tmp = FFCore.tempScreens[layer];
22237
22238 99149855 newcombo const& cmb1 = combobuf[tmp->data[pos1]];
22239
2/2
✓ Branch 0 taken 99148652 times.
✓ Branch 1 taken 1203 times.
99149855 if(cmb1.triggerflags[1] & combotriggerPUSH)
22240
5/6
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 14 times.
1204 if(pushing && !(pushing % zc_max(1,cmb1.trig_pushtime)))
22241 1 do_trigger_combo(layer,pos1);
22242
22243
2/2
✓ Branch 0 taken 81512494 times.
✓ Branch 1 taken 17637361 times.
99149855 if(pos1==pos2) continue;
22244
22245 17637361 newcombo const& cmb2 = combobuf[tmp->data[pos2]];
22246
2/2
✓ Branch 0 taken 17637086 times.
✓ Branch 1 taken 275 times.
17637361 if(cmb2.triggerflags[1] & combotriggerPUSH)
22247
4/6
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
275 if(pushing && !(pushing % zc_max(1,cmb2.trig_pushtime)))
22248 do_trigger_combo(layer,pos2);
22249 17637361 }
22250
2/2
✓ Branch 0 taken 13158109 times.
✓ Branch 1 taken 1006156 times.
14164265 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
22251 {
22252 1006156 word c = tmpscr->numFFC();
22253
2/2
✓ Branch 0 taken 1006156 times.
✓ Branch 1 taken 3023611 times.
4029767 for(word i=0; i<c; i++)
22254 {
22255
4/4
✓ Branch 0 taken 2992120 times.
✓ Branch 1 taken 31491 times.
✓ Branch 2 taken 1323 times.
✓ Branch 3 taken 2990797 times.
3023611 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
22256 {
22257 32814 ffcdata& ffc = tmpscr->ffcs[i];
22258 32814 newcombo const& cmb3 = combobuf[ffc.data];
22259
1/2
✓ Branch 0 taken 32814 times.
✗ Branch 1 not taken.
32814 if(cmb3.triggerflags[1] & combotriggerPUSH)
22260 {
22261 if(pushing && !(pushing % zc_max(1,cmb3.trig_pushtime)))
22262 {
22263 do_trigger_combo_ffc(i);
22264 break;
22265 }
22266 }
22267 32814 }
22268 3023611 }
22269 1006156 }
22270 14164265 }
22271
22272 14164267 void HeroClass::checksigns() //Also checks for generic trigger buttons
22273 {
22274
5/6
✓ Branch 0 taken 14149573 times.
✓ Branch 1 taken 14694 times.
✓ Branch 2 taken 14130917 times.
✓ Branch 3 taken 18656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14130917 times.
14164267 if(toogam || z>0 || fakez>0) return;
22275
5/6
✓ Branch 0 taken 14011435 times.
✓ Branch 1 taken 119482 times.
✓ Branch 2 taken 236865 times.
✓ Branch 3 taken 13774570 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 236865 times.
14130917 if(msg_active || (msg_onscreen && get_qr(qr_MSGDISAPPEAR)))
22276 119482 return; //Don't overwrite a message waiting to be dismissed
22277 14011435 zfix bx, by;
22278 14011435 zfix bx2, by2;
22279 14011435 zfix fx(-1), fy(-1);
22280
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3377497 times.
✓ Branch 2 taken 2807085 times.
✓ Branch 3 taken 3777109 times.
✓ Branch 4 taken 4049744 times.
14011435 switch(dir)
22281 {
22282 case up:
22283 3377497 by = y + (bigHitbox ? -2 : 6);
22284 3377497 by2 = by;
22285 3377497 bx = x + 4;
22286 3377497 bx2 = bx + 8;
22287 3377497 break;
22288 case down:
22289 2807085 by = y + 17;
22290 2807085 by2 = by;
22291 2807085 bx = x + 4;
22292 2807085 bx2 = bx + 8;
22293 2807085 break;
22294 case left:
22295 3777109 by = y + (bigHitbox ? 0 : 8);
22296 3777109 by2 = y + 8;
22297 3777109 bx = x - 2;
22298 3777109 bx2 = x - 2;
22299 3777109 break;
22300 case right:
22301 4049744 by = y + (bigHitbox ? 0 : 8);
22302 4049744 by2 = y + 8;
22303 4049744 bx = x + 17;
22304 4049744 bx2 = x + 17;
22305 4049744 break;
22306 }
22307
22308 14011435 int32_t found = -1;
22309 14011435 int32_t foundffc = -1;
22310 14011435 int32_t found_lyr = 0;
22311 14011435 bool found_sign = false;
22312 14011435 int32_t tmp_cid = MAPCOMBO(bx,by);
22313 14011435 newcombo const* tmp_cmb = &combobuf[tmp_cid];
22314
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14011435 times.
✓ Branch 2 taken 14005242 times.
✓ Branch 3 taken 6193 times.
28022870 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
22315 14011435 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, -1))
22316 {
22317 6193 found = tmp_cid;
22318 6193 fx = bx; fy = by;
22319
2/2
✓ Branch 0 taken 12386 times.
✓ Branch 1 taken 6193 times.
18579 for (int32_t i = 0; i <= 1; ++i)
22320 {
22321
2/2
✓ Branch 0 taken 9401 times.
✓ Branch 1 taken 2985 times.
12386 if(tmpscr2[i].valid!=0)
22322 {
22323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2985 times.
2985 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22324 {
22325 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
22326 }
22327 else
22328 {
22329
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2985 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2985 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
22330 }
22331 2985 }
22332 12386 }
22333 6193 }
22334 14011435 tmp_cid = MAPCOMBO(bx2,by2);
22335 14011435 tmp_cmb = &combobuf[tmp_cid];
22336
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14011435 times.
✓ Branch 2 taken 14005114 times.
✓ Branch 3 taken 6321 times.
28022870 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
22337 14011435 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, -1))
22338 {
22339 6321 found = tmp_cid;
22340 6321 fx = bx2; fy = by2;
22341
2/2
✓ Branch 0 taken 12642 times.
✓ Branch 1 taken 6321 times.
18963 for (int32_t i = 0; i <= 1; ++i)
22342 {
22343
2/2
✓ Branch 0 taken 9745 times.
✓ Branch 1 taken 2897 times.
12642 if(tmpscr2[i].valid!=0)
22344 {
22345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2897 times.
2897 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22346 {
22347 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
22348 }
22349 else
22350 {
22351
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2897 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2897 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
22352 }
22353 2897 }
22354 12642 }
22355 6321 }
22356
22357
2/2
✓ Branch 0 taken 13011644 times.
✓ Branch 1 taken 999791 times.
14011435 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
22358 {
22359 999791 word c = tmpscr->numFFC();
22360
2/2
✓ Branch 0 taken 999791 times.
✓ Branch 1 taken 3001843 times.
4001634 for(word i=0; i<c; i++)
22361 {
22362
4/4
✓ Branch 0 taken 2970546 times.
✓ Branch 1 taken 31297 times.
✓ Branch 2 taken 1323 times.
✓ Branch 3 taken 2969223 times.
3001843 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
22363 {
22364 32620 ffcdata& ffc = tmpscr->ffcs[i];
22365 32620 tmp_cmb = &combobuf[ffc.data];
22366
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 32620 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32620 times.
32620 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
22367 32620 || tmp_cmb->triggerbtn) && true) //!TODO: FFC effect flag?
22368 {
22369 foundffc = i;
22370 break;
22371 }
22372 32620 }
22373 3001843 }
22374 999791 }
22375
22376
3/4
✓ Branch 0 taken 14004933 times.
✓ Branch 1 taken 6502 times.
✓ Branch 2 taken 14004933 times.
✗ Branch 3 not taken.
14011435 if(found<0 && foundffc < 0)
22377 {
22378
2/2
✓ Branch 0 taken 14002942 times.
✓ Branch 1 taken 84020342 times.
98023284 for(int32_t i=0; i<6; i++)
22379 {
22380 84020342 tmp_cid = MAPCOMBO2(i,bx,by);
22381 84020342 tmp_cmb = &combobuf[tmp_cid];
22382
4/4
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 84019648 times.
✓ Branch 2 taken 84018404 times.
✓ Branch 3 taken 1938 times.
168040684 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
22383 84020342 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, i))
22384 {
22385 1938 found = tmp_cid;
22386 1938 found_lyr = i+1;
22387 1938 fx = bx; fy = by;
22388
4/4
✓ Branch 0 taken 1277 times.
✓ Branch 1 taken 661 times.
✓ Branch 2 taken 360 times.
✓ Branch 3 taken 917 times.
1938 if (i == 0 && tmpscr2[1].valid!=0)
22389 {
22390
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 37 times.
917 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22391 {
22392
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
880 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
22393 880 }
22394 else
22395 {
22396
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
22397 }
22398 917 }
22399 1938 }
22400 84020342 tmp_cid = MAPCOMBO2(i,bx2,by2);
22401 84020342 tmp_cmb = &combobuf[tmp_cid];
22402
4/4
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 84019656 times.
✓ Branch 2 taken 84018511 times.
✓ Branch 3 taken 1831 times.
168040684 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
22403 84020342 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, i))
22404 {
22405 1831 found = tmp_cid;
22406 1831 found_lyr = i+1;
22407 1831 fx = bx2; fy = by2;
22408
4/4
✓ Branch 0 taken 1178 times.
✓ Branch 1 taken 653 times.
✓ Branch 2 taken 363 times.
✓ Branch 3 taken 815 times.
1831 if (i == 0 && tmpscr2[1].valid!=0)
22409 {
22410
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 35 times.
815 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22411 {
22412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
780 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
22413 780 }
22414 else
22415 {
22416
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
22417 }
22418 815 }
22419 1831 }
22420
2/2
✓ Branch 0 taken 84018351 times.
✓ Branch 1 taken 1991 times.
84020342 if(found>-1) break;
22421 84018351 }
22422 14004933 }
22423
22424
3/4
✓ Branch 0 taken 14002942 times.
✓ Branch 1 taken 8493 times.
✓ Branch 2 taken 14002942 times.
✗ Branch 3 not taken.
14011435 if(found<0&&foundffc<0) return;
22425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8493 times.
8493 newcombo const& cmb = (foundffc<0?combobuf[found]:combobuf[tmpscr->ffcs[foundffc].data]);
22426
22427 8493 byte signInput = 0;
22428 8493 bool didsign = false, didprompt = false;
22429
3/4
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 7761 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 732 times.
8512 if(cmb.type == cSIGNPOST && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
22430 {
22431
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 577 times.
✓ Branch 2 taken 116 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 35 times.
732 switch(dir)
22432 {
22433 case up:
22434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 577 times.
577 if(cmb.usrflags&cflag10)
22435 goto endsigns;
22436 577 break;
22437 case down:
22438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(cmb.usrflags&cflag9)
22439 goto endsigns;
22440 116 break;
22441 case left:
22442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(cmb.usrflags&cflag12)
22443 goto endsigns;
22444 4 break;
22445 case right:
22446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(cmb.usrflags&cflag11)
22447 goto endsigns;
22448 35 break;
22449 }
22450 732 int32_t intbtn = cmb.attribytes[2];
22451
22452
1/2
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
732 if(intbtn) //
22453 {
22454 732 signInput = getIntBtnInput(intbtn, true, true, false, false);
22455
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 713 times.
732 if(!signInput)
22456 {
22457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 713 times.
713 if(cmb.usrflags & cflag13) //display prompt
22458 {
22459 713 prompt_combo = cmb.attributes[1]/10000;
22460 713 prompt_cset = cmb.attribytes[4];
22461 713 prompt_x = cmb.attrishorts[0];
22462 713 prompt_y = cmb.attrishorts[1];
22463 713 didprompt = true;
22464 713 }
22465 713 goto endsigns; //Button not pressed
22466 }
22467 19 }
22468 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
22469
22470 19 trigger_sign(cmb);
22471 19 didsign = true;
22472 19 }
22473 endsigns:
22474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8493 times.
8493 if(cpos_get(found_lyr, COMBOPOS(fx,fy)).trig_cd) return;
22475
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 521 times.
✓ Branch 2 taken 6986 times.
✓ Branch 3 taken 488 times.
✓ Branch 4 taken 498 times.
8493 switch(dir)
22476 {
22477 case down:
22478
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 116 times.
521 if(!(cmb.triggerflags[0] & combotriggerBTN_TOP))
22479 116 return;
22480 405 break;
22481 case up:
22482
2/2
✓ Branch 0 taken 6409 times.
✓ Branch 1 taken 577 times.
6986 if(!(cmb.triggerflags[0] & combotriggerBTN_BOTTOM))
22483 577 return;
22484 6409 break;
22485 case right:
22486
2/2
✓ Branch 0 taken 453 times.
✓ Branch 1 taken 35 times.
488 if(!(cmb.triggerflags[0] & combotriggerBTN_LEFT))
22487 35 return;
22488 453 break;
22489 case left:
22490
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 79 times.
498 if(!(cmb.triggerflags[0] & combotriggerBTN_RIGHT))
22491 79 return;
22492 419 break;
22493 }
22494
4/6
✓ Branch 0 taken 7686 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7515 times.
✓ Branch 3 taken 171 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7515 times.
7686 if(cmb.triggerbtn && (getIntBtnInput(cmb.triggerbtn, true, true, false, false) || checkIntBtnVal(cmb.triggerbtn, signInput)))
22495 {
22496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 171 times.
171 if (foundffc >= 0)
22497 do_trigger_combo_ffc(foundffc, didsign ? ctrigIGNORE_SIGN : 0);
22498 else
22499 171 do_trigger_combo(found_lyr, COMBOPOS(fx,fy), didsign ? ctrigIGNORE_SIGN : 0);
22500 171 }
22501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7515 times.
7515 else if(didprompt)
22502 return;
22503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7515 times.
7515 else if(cmb.type == cBUTTONPROMPT)
22504 {
22505 prompt_combo = cmb.attributes[0]/10000;
22506 prompt_cset = cmb.attribytes[0];
22507 prompt_x = cmb.attrishorts[0];
22508 prompt_y = cmb.attrishorts[1];
22509 }
22510
2/2
✓ Branch 0 taken 6000 times.
✓ Branch 1 taken 1515 times.
7515 else if(cmb.prompt_cid)
22511 {
22512 6000 prompt_combo = cmb.prompt_cid;
22513 6000 prompt_cset = cmb.prompt_cs;
22514 6000 prompt_x = cmb.prompt_x;
22515 6000 prompt_y = cmb.prompt_y;
22516 6000 }
22517 14164267 }
22518
22519 14140122 void HeroClass::checklocked()
22520 {
22521
2/2
✓ Branch 0 taken 14694 times.
✓ Branch 1 taken 14125428 times.
14140122 if(toogam) return; //Walk through walls.
22522
2/2
✓ Branch 0 taken 6255958 times.
✓ Branch 1 taken 7869470 times.
14125428 if(!isdungeon()) return;
22523
4/4
✓ Branch 0 taken 6203706 times.
✓ Branch 1 taken 52252 times.
✓ Branch 2 taken 12798 times.
✓ Branch 3 taken 6190908 times.
6255958 if( !diagonalMovement && pushing!=8) return;
22524 //This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
22525
4/4
✓ Branch 0 taken 52252 times.
✓ Branch 1 taken 12798 times.
✓ Branch 2 taken 2677 times.
✓ Branch 3 taken 49575 times.
65050 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
22526
22527 15475 optional<int> openDir;
22528
3/4
✓ Branch 0 taken 12798 times.
✓ Branch 1 taken 2677 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12798 times.
15475 if ( diagonalMovement || get_qr(qr_DISABLE_4WAY_GRIDLOCK))
22529 {
22530
8/8
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 2534 times.
✓ Branch 2 taken 97 times.
✓ Branch 3 taken 46 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 41 times.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 32 times.
2677 if(y <= 32 && x >= 112 && x <= 128 && Y_DIR(dir) == up)
22531 32 openDir = up;
22532
8/8
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2325 times.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 124 times.
✓ Branch 4 taken 87 times.
✓ Branch 5 taken 109 times.
✓ Branch 6 taken 56 times.
✓ Branch 7 taken 31 times.
2645 else if(y >= 128 && x >= 112 && x <= 128 && Y_DIR(dir) == down)
22533 31 openDir = down;
22534
5/8
✓ Branch 0 taken 1468 times.
✓ Branch 1 taken 1146 times.
✓ Branch 2 taken 279 times.
✓ Branch 3 taken 1189 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 279 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2614 else if(y > 72 && y < 88 && x <= 32 && X_DIR(dir) == left)
22535 openDir = left;
22536
5/8
✓ Branch 0 taken 1468 times.
✓ Branch 1 taken 1146 times.
✓ Branch 2 taken 279 times.
✓ Branch 3 taken 1189 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 279 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2614 else if(y > 72 && y < 88 && x >= 208 && X_DIR(dir) == right)
22537 openDir = right;
22538 2677 }
22539 else
22540 {
22541
6/6
✓ Branch 0 taken 1751 times.
✓ Branch 1 taken 11047 times.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 1277 times.
✓ Branch 4 taken 61 times.
✓ Branch 5 taken 413 times.
12798 if(y <= 32 && x == 120 && Y_DIR(dir) == up)
22542 413 openDir = up;
22543
6/6
✓ Branch 0 taken 1806 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 1554 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 227 times.
12385 else if(y >= 128 && x == 120 && Y_DIR(dir) == down)
22544 227 openDir = down;
22545
6/6
✓ Branch 0 taken 1831 times.
✓ Branch 1 taken 10327 times.
✓ Branch 2 taken 339 times.
✓ Branch 3 taken 1492 times.
✓ Branch 4 taken 114 times.
✓ Branch 5 taken 225 times.
12158 else if(y == 80 && x <= 32 && X_DIR(dir) == left)
22546 225 openDir = left;
22547
6/6
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 10327 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 1183 times.
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 356 times.
11933 else if(y == 80 && x >= 208 && X_DIR(dir) == right)
22548 356 openDir = right;
22549 }
22550
2/2
✓ Branch 0 taken 14191 times.
✓ Branch 1 taken 1284 times.
15475 if(openDir)
22551 {
22552 1284 int d = *openDir;
22553
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 920 times.
1284 if(tmpscr->door[d]==dLOCKED)
22554 {
22555
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 14 times.
364 if(usekey())
22556 {
22557 350 putdoor(scrollbuf,0,d,dUNLOCKED);
22558 350 tmpscr->door[d]=dUNLOCKED;
22559 350 set_doorstate(d);
22560 350 sfx(WAV_DOOR);
22561 350 markBmap(-1);
22562 350 }
22563 14 else return;
22564 350 }
22565
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 56 times.
920 else if(tmpscr->door[d]==dBOSS)
22566 {
22567
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 5 times.
56 if(game->lvlitems[dlevel]&liBOSSKEY)
22568 {
22569 51 putdoor(scrollbuf,0,d,dOPENBOSS);
22570 51 tmpscr->door[d]=dOPENBOSS;
22571 51 set_doorstate(d);
22572 51 sfx(WAV_DOOR);
22573 51 markBmap(-1);
22574 // Run Boss Key Script
22575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3468 times.
3468 for ( int32_t q = 0; q < MAXITEMS; ++q )
22576
2/2
✓ Branch 0 taken 3417 times.
✓ Branch 1 taken 51 times.
3468 if ( itemsbuf[q].family == itype_bosskey )
22577 {
22578
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
51 if (itemsbuf[q].script && !(FFCore.doscript(ScriptType::Item, q) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
22579 {
22580 FFCore.reset_script_engine_data(ScriptType::Item, q);
22581 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q);
22582 FFCore.deallocateAllScriptOwned(ScriptType::Item, q);
22583 }
22584 51 break;
22585 }
22586 51 }
22587 5 else return;
22588 51 }
22589 1265 }
22590 14140122 }
22591
22592 14140122 void HeroClass::checkswordtap()
22593 {
22594
6/6
✓ Branch 0 taken 6858951 times.
✓ Branch 1 taken 7281171 times.
✓ Branch 2 taken 40969 times.
✓ Branch 3 taken 6817982 times.
✓ Branch 4 taken 40006 times.
✓ Branch 5 taken 963 times.
14140122 if(attack!=wSword || charging<=0 || pushing<8) return;
22595
22596 963 int32_t bx=x;
22597 963 int32_t by=y+8;
22598
22599
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 307 times.
✓ Branch 4 taken 262 times.
963 switch(dir)
22600 {
22601 case up:
22602
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 65 times.
282 if(!Up()) return;
22603
22604 217 by-=16;
22605 217 break;
22606
22607 case down:
22608
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 20 times.
112 if(!Down()) return;
22609
22610 92 by+=16;
22611 92 bx+=8;
22612 92 break;
22613
22614 case left:
22615
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 139 times.
307 if(!Left()) return;
22616
22617 168 bx-=16;
22618 168 by+=8;
22619 168 break;
22620
22621 case right:
22622
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 72 times.
262 if(!Right()) return;
22623
22624 190 bx+=16;
22625 190 by+=8;
22626 190 break;
22627 }
22628
22629
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 667 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 667 times.
✓ Branch 4 taken 513 times.
✓ Branch 5 taken 154 times.
667 if(!_walkflag(bx,by,0,SWITCHBLOCK_STATE)) return;
22630
22631 513 attackclk=SWORDTAPFRAME;
22632 513 pushing=-8; //16 frames between taps
22633 513 tapping=true;
22634
22635 513 int32_t type = COMBOTYPE(bx,by);
22636
22637
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 500 times.
513 if(!isCuttableType(type))
22638 {
22639 500 int tap_sfx = -1;
22640 500 auto pos = COMBOPOS(bx,by);
22641 500 bool hollow = false;
22642
2/2
✓ Branch 0 taken 500 times.
✓ Branch 1 taken 4000 times.
4500 for(int lyr = 7; lyr >= 0; --lyr)
22643 {
22644 4000 mapscr* m = FFCore.tempScreens[lyr];
22645 4000 newcombo const& cmb = combobuf[m->data[pos]];
22646
1/2
✓ Branch 0 taken 4000 times.
✗ Branch 1 not taken.
4000 if(cmb.sfx_tap)
22647 {
22648 tap_sfx = cmb.sfx_tap;
22649 break;
22650 }
22651
3/4
✓ Branch 0 taken 3991 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3991 times.
7991 if(m->sflag[pos] == mfBOMB || m->sflag[pos] == mfSBOMB
22652
2/4
✓ Branch 0 taken 3991 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3991 times.
✗ Branch 3 not taken.
3991 || cmb.flag == mfBOMB || cmb.flag == mfSBOMB)
22653 9 hollow = true;
22654 4000 }
22655
2/4
✓ Branch 0 taken 500 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500 times.
500 if(tap_sfx < 0 && get_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX))
22656 {
22657
3/10
✓ Branch 0 taken 491 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 491 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
500 if(hollow || (tmpscr->door[dir]==dBOMB && ((dir==up||dir==down)
22658 ? (bx>=112 && bx<144 && (by>=144 || by<=32))
22659 : by>=72 && by<104 && (bx>=224 || bx<=32))))
22660 9 tap_sfx = QMisc.miscsfx[sfxTAP_HOLLOW];
22661 500 }
22662
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 491 times.
500 if(tap_sfx < 0)
22663 491 tap_sfx = QMisc.miscsfx[sfxTAP];
22664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 500 times.
500 if(tap_sfx)
22665 500 sfx(tap_sfx,pan(x.getInt()));
22666 500 }
22667 14140122 }
22668
22669 27606 void HeroClass::fairycircle(int32_t type)
22670 {
22671
2/2
✓ Branch 0 taken 23253 times.
✓ Branch 1 taken 4353 times.
27606 if(fairyclk==0)
22672 {
22673
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4333 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 19 times.
4353 switch(type)
22674 {
22675 case REFILL_LIFE:
22676
2/2
✓ Branch 0 taken 4177 times.
✓ Branch 1 taken 156 times.
4333 if(didstuff&did_fairy) return;
22677
22678 156 didstuff|=did_fairy;
22679 156 break;
22680
22681 case REFILL_MAGIC:
22682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(didstuff&did_magic) return;
22683
22684 1 didstuff|=did_magic;
22685 1 break;
22686
22687 case REFILL_ALL:
22688
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2 times.
19 if(didstuff&did_all) return;
22689
22690 2 didstuff|=did_all;
22691 2 }
22692
22693 159 refill_what=type;
22694 159 refill_why=REFILL_FAIRY;
22695 159 StartRefill(type);
22696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
22697 159 else {action=freeze; FFCore.setHeroAction(freeze);}
22698 159 holdclk=0;
22699 159 hopclk=0;
22700 159 }
22701
22702 23412 ++fairyclk;
22703
22704
2/2
✓ Branch 0 taken 10557 times.
✓ Branch 1 taken 12855 times.
23412 if(refilling!=REFILL_FAIRYDONE)
22705 {
22706
2/2
✓ Branch 0 taken 10398 times.
✓ Branch 1 taken 159 times.
10557 if(!refill())
22707 159 refilling=REFILL_FAIRYDONE;
22708 10557 }
22709
22710
2/2
✓ Branch 0 taken 12697 times.
✓ Branch 1 taken 158 times.
12855 else if(++holdclk>80)
22711 {
22712 158 reset_swordcharge();
22713 158 attackclk=0;
22714 158 action=none; FFCore.setHeroAction(none);
22715 158 fairyclk=0;
22716 158 holdclk=0;
22717 158 refill_why = 0;
22718 158 refilling=REFILL_NONE;
22719 158 map_bkgsfx(true);
22720 158 }
22721 27606 }
22722
22723 1391446 int32_t touchcombo(int32_t x,int32_t y)
22724 {
22725
2/2
✓ Branch 0 taken 2782824 times.
✓ Branch 1 taken 1391378 times.
4174202 for (int32_t i = 0; i <= 1; ++i)
22726 {
22727
2/2
✓ Branch 0 taken 1951346 times.
✓ Branch 1 taken 831478 times.
2782824 if(tmpscr2[i].valid!=0)
22728 {
22729
2/2
✓ Branch 0 taken 667069 times.
✓ Branch 1 taken 164409 times.
831478 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22730 {
22731
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 667069 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
667069 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
22732 667069 }
22733 else
22734 {
22735
4/4
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 164308 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 68 times.
164409 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
22736 }
22737 831410 }
22738 2782756 }
22739
2/2
✓ Branch 0 taken 1389760 times.
✓ Branch 1 taken 1618 times.
1391378 if (!_effectflag(x,y,1, -1)) return 0;
22740 1389760 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
22741
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 1389712 times.
1389760 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
22742 48 return 0;
22743
3/3
✓ Branch 0 taken 3242 times.
✓ Branch 1 taken 1384543 times.
✓ Branch 2 taken 1927 times.
1389712 switch(cmb.type)
22744 {
22745 case cBSGRAVE:
22746 case cGRAVE:
22747
3/4
✓ Branch 0 taken 2255 times.
✓ Branch 1 taken 987 times.
✓ Branch 2 taken 2255 times.
✗ Branch 3 not taken.
3242 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
22748 {
22749 987 break;
22750 }
22751
22752 [[fallthrough]];
22753 case cARMOS:
22754 {
22755 4182 return cmb.type;
22756 }
22757 }
22758
22759 1385530 return 0;
22760 1391446 }
22761
22762 //static int32_t COMBOX(int32_t pos) { return ((pos)%16*16); }
22763 //static int32_t COMBOY(int32_t pos) { return ((pos)&0xF0); }
22764
22765 static int32_t GridX(int32_t x)
22766 {
22767 return (x >> 4) << 4;
22768 }
22769
22770 //Snaps 'y' to the combo grid
22771 //Equivalent to calling ComboY(ComboAt(foo,y));
22772 static int32_t GridY(int32_t y)
22773 {
22774 return (y >> 4) << 4;
22775 }
22776
22777 9 int32_t grabComboFromPos(int32_t pos, int32_t type)
22778 {
22779
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 for(int32_t lyr = 6; lyr > -1; --lyr)
22780 {
22781 63 int32_t id = FFCore.tempScreens[lyr]->data[pos];
22782
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 54 times.
63 if(combobuf[id].type == type)
22783 9 return id;
22784 54 }
22785 return -1;
22786 9 }
22787
22788 typedef word spot_t;
22789 static int32_t typeMap[176];
22790 static int32_t customTypeMap[176];
22791 static int32_t istrig[176];
22792 static int32_t heropos = -1;
22793 static const int32_t SPTYPE_SOLID = -1;
22794 enum
22795 {
22796 beamoffs_gr, beamoffs_up, beamoffs_down, beamoffs_left, beamoffs_right,
22797 beamoffs_uleft, beamoffs_uright, beamoffs_dleft, beamoffs_dright, beamoffs_vert,
22798 beamoffs_horz, beamoffs_notup, beamoffs_notdown, beamoffs_notleft, beamoffs_notright,
22799 beamoffs_all, beamoffs_max
22800 };
22801 struct lightbeam_xy
22802 {
22803 int16_t x;
22804 int16_t y;
22805 lightbeam_xy(int32_t nx, int32_t ny)
22806 {
22807 x = vbound(nx,-32768,32767);
22808 y = vbound(ny,-32768,32767);
22809 }
22810 lightbeam_xy(dword ffpos)
22811 {
22812 x = int16_t(ffpos >> 16);
22813 y = int16_t(ffpos & 0xFFFF);
22814 }
22815 bool valid() const
22816 {
22817 return valid(x,y);
22818 }
22819 void bound()
22820 {
22821 x = vbound(x,0-16,255+16);
22822 y = vbound(y,0-16,175+16);
22823 }
22824 dword ffpos() const
22825 {
22826 return (word(x)<<16)|word(y&0xFFFF);
22827 }
22828 size_t pos() const
22829 {
22830 return COMBOPOS(vbound(x,0,255),vbound(y,0,175));
22831 }
22832 bool herocollide(byte beamwid)
22833 {
22834 int bx = x-beamwid/2, by = y-beamwid/2;
22835 int hx = Hero.x.getInt(), hy = Hero.y.getInt();
22836 return hx+15 >= bx && hx < bx+beamwid
22837 && hy+15 >= by && hy < by+beamwid;
22838 }
22839 static bool valid(int32_t x, int32_t y)
22840 {
22841 return x+16 >= 0 && x-16 < 256 && y+16 >= 0 && y-16 < 176;
22842 }
22843 };
22844 #define SP_VISITED 0x1
22845 #define SP_FLAGS 0x01E
22846 #define SP_GOFLAGS 0x1E0
22847 #define SP_MASK (SP_VISITED|SP_FLAGS)
22848 #define SP_FLAG(dir) (0x2<<dir)
22849 #define SP_GOFLAG(dir) (0x20<<dir)
22850 #define BEAM_AGE_LIMIT 512
22851 14283 static void handleBeam(spot_t* grid, size_t age, byte spotdir, int32_t curpos, byte set, bool block, bool refl)
22852 {
22853
2/2
✓ Branch 0 taken 7620 times.
✓ Branch 1 taken 6663 times.
14283 if(spotdir > 3) return; //invalid dir
22854
2/2
✓ Branch 0 taken 5429 times.
✓ Branch 1 taken 1234 times.
6663 int32_t trigflag = set ? (1 << (set-1)) : ~0;
22855 6663 bool doAge = true;
22856 6663 spot_t f = 0;
22857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70632 times.
70632 while(unsigned(curpos) < 176)
22858 {
22859 70632 bool block_light = false;
22860 70632 f = SP_GOFLAG(spotdir);
22861
2/2
✓ Branch 0 taken 70177 times.
✓ Branch 1 taken 455 times.
70632 if((grid[curpos] & f) == f)
22862 455 return;
22863 70177 else grid[curpos] |= f;
22864 70177 f = SP_FLAG(spotdir);
22865
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 70024 times.
70177 if((grid[curpos] & f) != f)
22866 {
22867 70024 grid[curpos] |= f;
22868 70024 istrig[curpos] |= trigflag;
22869 70024 doAge = false;
22870 70024 age = 0;
22871 70024 }
22872
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 16931 times.
✓ Branch 2 taken 9603 times.
✓ Branch 3 taken 23595 times.
✓ Branch 4 taken 20048 times.
70177 switch(spotdir)
22873 {
22874 case up:
22875 16931 curpos -= 0x10;
22876 16931 break;
22877 case down:
22878 9603 curpos += 0x10;
22879 9603 break;
22880 case left:
22881
1/2
✓ Branch 0 taken 23595 times.
✗ Branch 1 not taken.
23595 if(!(curpos%0x10))
22882 curpos = -1;
22883 23595 else --curpos;
22884 23595 break;
22885 case right:
22886 20048 ++curpos;
22887
1/2
✓ Branch 0 taken 20048 times.
✗ Branch 1 not taken.
20048 if(!(curpos%0x10))
22888 curpos = -1;
22889 20048 break;
22890 }
22891
1/2
✓ Branch 0 taken 70177 times.
✗ Branch 1 not taken.
70177 if(unsigned(curpos) >= 176) return;
22892
2/2
✓ Branch 0 taken 6208 times.
✓ Branch 1 taken 63969 times.
70177 switch(typeMap[curpos])
22893 {
22894 case SPTYPE_SOLID: case cBLOCKALL:
22895 6208 curpos = -1;
22896 6208 break;
22897 }
22898
3/6
✓ Branch 0 taken 1061 times.
✓ Branch 1 taken 69116 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1061 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
70177 if((curpos==heropos) && block && (spotdir == oppositeDir[Hero.getDir()]))
22899 curpos = -1;
22900
2/2
✓ Branch 0 taken 63969 times.
✓ Branch 1 taken 6208 times.
70177 if(unsigned(curpos) >= 176) return;
22901
22902 63969 f = SP_FLAG(oppositeDir[spotdir]);
22903
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 63816 times.
63969 if((grid[curpos] & f) != f)
22904 {
22905 63816 grid[curpos] |= f;
22906 63816 istrig[curpos] |= trigflag;
22907 63816 doAge = false;
22908 63816 age = 0;
22909 63816 }
22910
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 63816 times.
63969 if(doAge)
22911 {
22912
1/2
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
153 if(++age > BEAM_AGE_LIMIT)
22913 return;
22914 153 }
22915 63816 else doAge = true;
22916
22917
4/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 63094 times.
✓ Branch 2 taken 147 times.
✓ Branch 3 taken 728 times.
63969 if(curpos==heropos && refl)
22918 728 spotdir = Hero.getDir();
22919
4/8
✓ Branch 0 taken 46363 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9088 times.
✓ Branch 4 taken 7781 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
63241 else switch(typeMap[curpos])
22920 {
22921 case cLIGHTTARGET:
22922 {
22923 9 auto cid = grabComboFromPos(curpos, cLIGHTTARGET);
22924
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 if(cid > -1 && combobuf[cid].usrflags&cflag3) //Blocks light
22925 return;
22926
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
9 if(get_qr(qr_BROKEN_LIGHTBEAM_HITBOX))
22927 6 spotdir = oppositeDir[spotdir];
22928 9 break;
22929 }
22930 case cMIRROR:
22931 spotdir = oppositeDir[spotdir];
22932 break;
22933 case cMIRRORSLASH:
22934
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2991 times.
✓ Branch 2 taken 3402 times.
✓ Branch 3 taken 1726 times.
✓ Branch 4 taken 969 times.
9088 switch(spotdir)
22935 {
22936 case up:
22937 2991 spotdir = right; break;
22938 case right:
22939 3402 spotdir = up; break;
22940 case down:
22941 1726 spotdir = left; break;
22942 case left:
22943 969 spotdir = down; break;
22944 }
22945 9088 break;
22946 case cMIRRORBACKSLASH:
22947
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1927 times.
✓ Branch 2 taken 1814 times.
✓ Branch 3 taken 1522 times.
✓ Branch 4 taken 2518 times.
7781 switch(spotdir)
22948 {
22949 case up:
22950 1927 spotdir = left; break;
22951 case left:
22952 1814 spotdir = up; break;
22953 case down:
22954 1522 spotdir = right; break;
22955 case right:
22956 2518 spotdir = down; break;
22957 }
22958 7781 break;
22959 case cMAGICPRISM:
22960 for(byte d = 0; d < 4; ++d)
22961 {
22962 if(d == oppositeDir[spotdir]) continue;
22963 handleBeam(grid, age, d, curpos, set, block, refl);
22964 }
22965 return;
22966 case cMAGICPRISM4:
22967 for(byte d = 0; d < 4; ++d)
22968 {
22969 handleBeam(grid, age, d, curpos, set, block, refl);
22970 }
22971 return;
22972 case cMIRRORNEW:
22973 {
22974 auto cid = customTypeMap[curpos];
22975 if(unsigned(cid) >= MAXCOMBOS) break;
22976 newcombo const& cmb = combobuf[cid];
22977 byte newdir = cmb.attribytes[spotdir];
22978 if(newdir > 7) return;
22979 if(newdir > 3) break;
22980 spotdir = newdir;
22981 break;
22982 }
22983 }
22984 }
22985 14283 }
22986 static void handleFFBeam(std::map<dword,spot_t>& grid, size_t age, byte spotdir, lightbeam_xy curxy, byte set, bool block, bool refl, byte beamwid)
22987 {
22988 if(spotdir > 3) return; //invalid dir
22989 int32_t trigflag = set ? (1 << (set-1)) : ~0;
22990 bool doAge = true;
22991 byte f = 0;
22992 while(curxy.valid())
22993 {
22994 bool block_light = false;
22995 f = SP_FLAG(spotdir);
22996 if((grid[curxy.ffpos()] & f) != f)
22997 {
22998 grid[curxy.ffpos()] |= f;
22999 istrig[curxy.pos()] |= trigflag;
23000 doAge = false;
23001 age = 0;
23002 }
23003 switch(spotdir)
23004 {
23005 case up:
23006 curxy.y -= 16;
23007 break;
23008 case down:
23009 curxy.y += 16;
23010 break;
23011 case left:
23012 curxy.x -= 16;
23013 break;
23014 case right:
23015 curxy.x += 16;
23016 break;
23017 }
23018 auto curpos = curxy.pos();
23019 switch(typeMap[curpos])
23020 {
23021 case SPTYPE_SOLID: case cBLOCKALL:
23022 return;
23023 case cMIRRORNEW:
23024 {
23025 auto cid = customTypeMap[curpos];
23026 if(unsigned(cid) >= MAXCOMBOS) break;
23027 newcombo const& cmb = combobuf[cid];
23028 byte newdir = cmb.attribytes[spotdir];
23029 if(newdir > 7) return;
23030 break;
23031 }
23032 }
23033 bool collided_hero = heropos > -1 && curxy.herocollide(beamwid);
23034 if(block && (spotdir == oppositeDir[Hero.getDir()]) && collided_hero)
23035 return;
23036
23037 f = SP_FLAG(oppositeDir[spotdir]);
23038 if((grid[curxy.ffpos()] & f) != f)
23039 {
23040 grid[curxy.ffpos()] |= f;
23041 istrig[curpos] |= trigflag;
23042 doAge = false;
23043 age = 0;
23044 }
23045 if(!curxy.valid()) return;
23046 if(doAge)
23047 {
23048 if(++age > BEAM_AGE_LIMIT)
23049 return;
23050 }
23051 else doAge = true;
23052
23053 if(refl && collided_hero)
23054 spotdir = Hero.getDir();
23055 else switch(typeMap[curpos])
23056 {
23057 case cLIGHTTARGET:
23058 {
23059 auto cid = grabComboFromPos(curpos, cLIGHTTARGET);
23060 if(cid > -1 && combobuf[cid].usrflags&cflag3) //Blocks light
23061 return;
23062 if(get_qr(qr_BROKEN_LIGHTBEAM_HITBOX))
23063 spotdir = oppositeDir[spotdir];
23064 break;
23065 }
23066 case cMIRROR:
23067 spotdir = oppositeDir[spotdir];
23068 break;
23069 case cMIRRORSLASH:
23070 switch(spotdir)
23071 {
23072 case up:
23073 spotdir = right; break;
23074 case right:
23075 spotdir = up; break;
23076 case down:
23077 spotdir = left; break;
23078 case left:
23079 spotdir = down; break;
23080 }
23081 break;
23082 case cMIRRORBACKSLASH:
23083 switch(spotdir)
23084 {
23085 case up:
23086 spotdir = left; break;
23087 case left:
23088 spotdir = up; break;
23089 case down:
23090 spotdir = right; break;
23091 case right:
23092 spotdir = down; break;
23093 }
23094 break;
23095 case cMAGICPRISM:
23096 for(byte d = 0; d < 4; ++d)
23097 {
23098 if(d == oppositeDir[spotdir]) continue;
23099 handleFFBeam(grid, age, d, curxy, set, block, refl, beamwid);
23100 }
23101 return;
23102 case cMAGICPRISM4:
23103 for(byte d = 0; d < 4; ++d)
23104 {
23105 handleFFBeam(grid, age, d, curxy, set, block, refl, beamwid);
23106 }
23107 return;
23108 case cMIRRORNEW:
23109 {
23110 auto cid = customTypeMap[curpos];
23111 if(unsigned(cid) >= MAXCOMBOS) break;
23112 newcombo const& cmb = combobuf[cid];
23113 byte newdir = cmb.attribytes[spotdir];
23114 if(newdir > 3) break;
23115 spotdir = newdir;
23116 break;
23117 }
23118 }
23119 }
23120 }
23121
23122 #define BEAMID_COLOR0 (1<<24) //must have rightmost 24 bits empty
23123 14283 static int get_beamid(newcombo const& cmb)
23124 {
23125 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
23126
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 13049 times.
14283 if(cmb.usrflags&cflag1) //use tile/cset style
23127 1234 return std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24;
23128 else //use 3-color style
23129 {
23130 13049 auto id = -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
23131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13049 times.
13049 if(!id) //0 would clash with the tile/cset style
23132 id = BEAMID_COLOR0;
23133 13049 return id;
23134 }
23135 14283 }
23136 14283 static bool launch_lightbeam(newcombo const& cmb, int32_t pos,
23137 std::map<int32_t, spot_t*>& maps, bool refl, bool block)
23138 {
23139 14283 int32_t id = get_beamid(cmb);
23140 //Get the grid array for this tile/color
23141 spot_t* grid;
23142
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 if(maps[id])
23143 grid = maps[id];
23144 else
23145 {
23146 14283 grid = new spot_t[176];
23147 14283 memset(grid, 0, sizeof(spot_t)*176);
23148 14283 maps[id] = grid;
23149 }
23150 14283 byte spotdir = cmb.attribytes[0];
23151
2/2
✓ Branch 0 taken 3861 times.
✓ Branch 1 taken 10422 times.
14283 if(spotdir > 3)
23152 {
23153 10422 grid[pos] |= SP_VISITED;
23154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10422 times.
10422 istrig[pos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
23155 10422 }
23156
4/4
✓ Branch 0 taken 10892 times.
✓ Branch 1 taken 3391 times.
✓ Branch 2 taken 8090 times.
✓ Branch 3 taken 2802 times.
14283 if(refl && pos == heropos)
23157 {
23158 2802 spotdir = Hero.getDir();
23159 2802 }
23160 14283 handleBeam(grid, 0, spotdir, pos, cmb.attribytes[4], block, refl);
23161 14283 return true;
23162 }
23163
23164 static bool launch_fflightbeam(ffcdata const& ffc,
23165 std::map<int32_t, std::map<dword,spot_t>>& ffmaps, bool refl, bool block)
23166 {
23167 newcombo const& cmb = combobuf[ffc.data];
23168 int32_t id = get_beamid(cmb);
23169 //Get the grid array for this tile/color
23170 std::map<dword,spot_t>& grid = ffmaps[id]; // grid of (x<<16)|(y&0xFFFF)
23171 byte spotdir = cmb.attribytes[0];
23172 lightbeam_xy sxy(ffc.x+(ffc.hit_width/2), ffc.y+(ffc.hit_height/2));
23173 if(spotdir > 3 && sxy.valid())
23174 {
23175 grid[sxy.ffpos()] |= SP_VISITED;
23176 int32_t trigflag = cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
23177 istrig[sxy.pos()] |= trigflag;
23178 }
23179 auto beamwid = cmb.attribytes[5] < 1 ? 8 : cmb.attribytes[5];
23180 if(refl && heropos > -1 && sxy.herocollide(beamwid))
23181 {
23182 spotdir = Hero.getDir();
23183 }
23184 switch(spotdir)
23185 {
23186 case up:
23187 sxy.y = zc_min(175,sxy.y);
23188 break;
23189 case down:
23190 sxy.y = zc_max(0,sxy.y);
23191 break;
23192 case left:
23193 sxy.x = zc_min(255,sxy.x);
23194 break;
23195 case right:
23196 sxy.x = zc_max(0,sxy.x);
23197 break;
23198 }
23199 handleFFBeam(grid, 0, spotdir, sxy, cmb.attribytes[4], block, refl, beamwid);
23200 return true;
23201 }
23202
23203 14283 static BITMAP* generate_beam_bitmap(int32_t id)
23204 {
23205 14283 BITMAP* cbmp = create_bitmap_ex(8, 16*beamoffs_max, 16);
23206 14283 clear_bitmap(cbmp);
23207
3/4
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 13049 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1234 times.
14283 if(id < 0 || id == BEAMID_COLOR0)
23208 {
23209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13049 times.
13049 int cid = (id == BEAMID_COLOR0) ? 0 : abs(id);
23210 13049 byte c_inner = (cid & 0x0000FF);
23211 13049 byte c_middle = (cid & 0x00FF00)>>8;
23212 13049 byte c_outter = (cid & 0xFF0000)>>16;
23213
2/2
✓ Branch 0 taken 195735 times.
✓ Branch 1 taken 13049 times.
208784 for(size_t q = 1; q < beamoffs_max; ++q)
23214 {
23215 195735 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
23216 195735 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
23217 195735 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
23218 195735 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
23219 195735 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
23220 195735 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
23221 195735 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
23222 195735 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
23223 195735 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
23224 195735 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
23225 195735 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
23226 195735 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
23227 195735 }
23228 //beamoffs_gr
23229 13049 circlefill(cbmp, 16*beamoffs_gr+8, 8, 7, c_outter);
23230 13049 circlefill(cbmp, 16*beamoffs_gr+7, 8, 7, c_outter);
23231 13049 circlefill(cbmp, 16*beamoffs_gr+8, 7, 7, c_outter);
23232 13049 circlefill(cbmp, 16*beamoffs_gr+7, 7, 7, c_outter);
23233 13049 circlefill(cbmp, 16*beamoffs_gr+8, 8, 5, c_middle);
23234 13049 circlefill(cbmp, 16*beamoffs_gr+7, 8, 5, c_middle);
23235 13049 circlefill(cbmp, 16*beamoffs_gr+8, 7, 5, c_middle);
23236 13049 circlefill(cbmp, 16*beamoffs_gr+7, 7, 5, c_middle);
23237 13049 circlefill(cbmp, 16*beamoffs_gr+8, 8, 3, c_inner);
23238 13049 circlefill(cbmp, 16*beamoffs_gr+7, 8, 3, c_inner);
23239 13049 circlefill(cbmp, 16*beamoffs_gr+8, 7, 3, c_inner);
23240 13049 circlefill(cbmp, 16*beamoffs_gr+7, 7, 3, c_inner);
23241 //beamoffs_up
23242 13049 rectfill(cbmp, 16*beamoffs_up+4, 0, 16*beamoffs_up+11, 7, c_outter);
23243 13049 rectfill(cbmp, 16*beamoffs_up+6, 0, 16*beamoffs_up+9, 7, c_middle);
23244 13049 rectfill(cbmp, 16*beamoffs_up+7, 0, 16*beamoffs_up+8, 7, c_inner);
23245 //beamoffs_down
23246 13049 rectfill(cbmp, 16*beamoffs_down+4, 8, 16*beamoffs_down+11, 15, c_outter);
23247 13049 rectfill(cbmp, 16*beamoffs_down+6, 8, 16*beamoffs_down+9, 15, c_middle);
23248 13049 rectfill(cbmp, 16*beamoffs_down+7, 8, 16*beamoffs_down+8, 15, c_inner);
23249 //beamoffs_left
23250 13049 rectfill(cbmp, 16*beamoffs_left, 4, 16*beamoffs_left+7, 11, c_outter);
23251 13049 rectfill(cbmp, 16*beamoffs_left, 6, 16*beamoffs_left+7, 9, c_middle);
23252 13049 rectfill(cbmp, 16*beamoffs_left, 7, 16*beamoffs_left+7, 8, c_inner);
23253 //beamoffs_right
23254 13049 rectfill(cbmp, 16*beamoffs_right+8, 4, 16*beamoffs_right+15, 11, c_outter);
23255 13049 rectfill(cbmp, 16*beamoffs_right+8, 6, 16*beamoffs_right+15, 9, c_middle);
23256 13049 rectfill(cbmp, 16*beamoffs_right+8, 7, 16*beamoffs_right+15, 8, c_inner);
23257 //beamoffs_uleft
23258 13049 rectfill(cbmp, 16*beamoffs_uleft+4, 0, 16*beamoffs_uleft+11, 7, c_outter);
23259 13049 rectfill(cbmp, 16*beamoffs_uleft, 4, 16*beamoffs_uleft+7, 11, c_outter);
23260 13049 rectfill(cbmp, 16*beamoffs_uleft, 6, 16*beamoffs_uleft+7, 9, c_middle);
23261 13049 rectfill(cbmp, 16*beamoffs_uleft+6, 0, 16*beamoffs_uleft+9, 7, c_middle);
23262 13049 rectfill(cbmp, 16*beamoffs_uleft+7, 0, 16*beamoffs_uleft+8, 7, c_inner);
23263 13049 rectfill(cbmp, 16*beamoffs_uleft, 7, 16*beamoffs_uleft+7, 8, c_inner);
23264 //beamoffs_uright
23265 13049 rectfill(cbmp, 16*beamoffs_uright+4, 0, 16*beamoffs_uright+11, 7, c_outter);
23266 13049 rectfill(cbmp, 16*beamoffs_uright+8, 4, 16*beamoffs_uright+15, 11, c_outter);
23267 13049 rectfill(cbmp, 16*beamoffs_uright+8, 6, 16*beamoffs_uright+15, 9, c_middle);
23268 13049 rectfill(cbmp, 16*beamoffs_uright+6, 0, 16*beamoffs_uright+9, 7, c_middle);
23269 13049 rectfill(cbmp, 16*beamoffs_uright+7, 0, 16*beamoffs_uright+8, 7, c_inner);
23270 13049 rectfill(cbmp, 16*beamoffs_uright+8, 7, 16*beamoffs_uright+15, 8, c_inner);
23271 //beamoffs_dleft
23272 13049 rectfill(cbmp, 16*beamoffs_dleft+4, 8, 16*beamoffs_dleft+11, 15, c_outter);
23273 13049 rectfill(cbmp, 16*beamoffs_dleft, 4, 16*beamoffs_dleft+7, 11, c_outter);
23274 13049 rectfill(cbmp, 16*beamoffs_dleft, 6, 16*beamoffs_dleft+7, 9, c_middle);
23275 13049 rectfill(cbmp, 16*beamoffs_dleft+6, 8, 16*beamoffs_dleft+9, 15, c_middle);
23276 13049 rectfill(cbmp, 16*beamoffs_dleft+7, 8, 16*beamoffs_dleft+8, 15, c_inner);
23277 13049 rectfill(cbmp, 16*beamoffs_dleft, 7, 16*beamoffs_dleft+7, 8, c_inner);
23278 //beamoffs_dright
23279 13049 rectfill(cbmp, 16*beamoffs_dright+4, 8, 16*beamoffs_dright+11, 15, c_outter);
23280 13049 rectfill(cbmp, 16*beamoffs_dright+8, 4, 16*beamoffs_dright+15, 11, c_outter);
23281 13049 rectfill(cbmp, 16*beamoffs_dright+8, 6, 16*beamoffs_dright+15, 9, c_middle);
23282 13049 rectfill(cbmp, 16*beamoffs_dright+6, 8, 16*beamoffs_dright+9, 15, c_middle);
23283 13049 rectfill(cbmp, 16*beamoffs_dright+7, 8, 16*beamoffs_dright+8, 15, c_inner);
23284 13049 rectfill(cbmp, 16*beamoffs_dright+8, 7, 16*beamoffs_dright+15, 8, c_inner);
23285 //beamoffs_vert
23286 13049 rectfill(cbmp, 16*beamoffs_vert+4, 0, 16*beamoffs_vert+11, 15, c_outter);
23287 13049 rectfill(cbmp, 16*beamoffs_vert+6, 0, 16*beamoffs_vert+9, 15, c_middle);
23288 13049 rectfill(cbmp, 16*beamoffs_vert+7, 0, 16*beamoffs_vert+8, 15, c_inner);
23289 //beamoffs_horz
23290 13049 rectfill(cbmp, 16*beamoffs_horz, 4, 16*beamoffs_horz+15, 11, c_outter);
23291 13049 rectfill(cbmp, 16*beamoffs_horz, 6, 16*beamoffs_horz+15, 9, c_middle);
23292 13049 rectfill(cbmp, 16*beamoffs_horz, 7, 16*beamoffs_horz+15, 8, c_inner);
23293 //beamoffs_notup
23294 13049 rectfill(cbmp, 16*beamoffs_notup, 4, 16*beamoffs_notup+15, 11, c_outter);
23295 13049 rectfill(cbmp, 16*beamoffs_notup+4, 8, 16*beamoffs_notup+11, 15, c_outter);
23296 13049 rectfill(cbmp, 16*beamoffs_notup+6, 8, 16*beamoffs_notup+9, 15, c_middle);
23297 13049 rectfill(cbmp, 16*beamoffs_notup, 6, 16*beamoffs_notup+15, 9, c_middle);
23298 13049 rectfill(cbmp, 16*beamoffs_notup, 7, 16*beamoffs_notup+15, 8, c_inner);
23299 13049 rectfill(cbmp, 16*beamoffs_notup+7, 8, 16*beamoffs_notup+8, 15, c_inner);
23300 //beamoffs_notdown
23301 13049 rectfill(cbmp, 16*beamoffs_notdown, 4, 16*beamoffs_notdown+15, 11, c_outter);
23302 13049 rectfill(cbmp, 16*beamoffs_notdown+4, 0, 16*beamoffs_notdown+11, 7, c_outter);
23303 13049 rectfill(cbmp, 16*beamoffs_notdown+6, 0, 16*beamoffs_notdown+9, 7, c_middle);
23304 13049 rectfill(cbmp, 16*beamoffs_notdown, 6, 16*beamoffs_notdown+15, 9, c_middle);
23305 13049 rectfill(cbmp, 16*beamoffs_notdown, 7, 16*beamoffs_notdown+15, 8, c_inner);
23306 13049 rectfill(cbmp, 16*beamoffs_notdown+7, 0, 16*beamoffs_notdown+8, 7, c_inner);
23307 //beamoffs_notleft
23308 13049 rectfill(cbmp, 16*beamoffs_notleft+4, 0, 16*beamoffs_notleft+11, 15, c_outter);
23309 13049 rectfill(cbmp, 16*beamoffs_notleft+8, 4, 16*beamoffs_notleft+15, 11, c_outter);
23310 13049 rectfill(cbmp, 16*beamoffs_notleft+8, 6, 16*beamoffs_notleft+15, 9, c_middle);
23311 13049 rectfill(cbmp, 16*beamoffs_notleft+6, 0, 16*beamoffs_notleft+9, 15, c_middle);
23312 13049 rectfill(cbmp, 16*beamoffs_notleft+7, 0, 16*beamoffs_notleft+8, 15, c_inner);
23313 13049 rectfill(cbmp, 16*beamoffs_notleft+8, 7, 16*beamoffs_notleft+15, 8, c_inner);
23314 //beamoffs_notright
23315 13049 rectfill(cbmp, 16*beamoffs_notright+4, 0, 16*beamoffs_notright+11, 15, c_outter);
23316 13049 rectfill(cbmp, 16*beamoffs_notright, 4, 16*beamoffs_notright+7, 11, c_outter);
23317 13049 rectfill(cbmp, 16*beamoffs_notright, 6, 16*beamoffs_notright+7, 9, c_middle);
23318 13049 rectfill(cbmp, 16*beamoffs_notright+6, 0, 16*beamoffs_notright+9, 15, c_middle);
23319 13049 rectfill(cbmp, 16*beamoffs_notright+7, 0, 16*beamoffs_notright+8, 15, c_inner);
23320 13049 rectfill(cbmp, 16*beamoffs_notright, 7, 16*beamoffs_notright+7, 8, c_inner);
23321 //beamoffs_all
23322 13049 rectfill(cbmp, 16*beamoffs_all+4, 0, 16*beamoffs_all+11, 15, c_outter);
23323 13049 rectfill(cbmp, 16*beamoffs_all, 4, 16*beamoffs_all+15, 11, c_outter);
23324 13049 rectfill(cbmp, 16*beamoffs_all, 6, 16*beamoffs_all+15, 9, c_middle);
23325 13049 rectfill(cbmp, 16*beamoffs_all+6, 0, 16*beamoffs_all+9, 15, c_middle);
23326 13049 rectfill(cbmp, 16*beamoffs_all+7, 0, 16*beamoffs_all+8, 15, c_inner);
23327 13049 rectfill(cbmp, 16*beamoffs_all, 7, 16*beamoffs_all+15, 8, c_inner);
23328 13049 }
23329 else
23330 {
23331 1234 int32_t tile = (id&0xFFFFFF);
23332 1234 int32_t cs = (id>>24);
23333
2/2
✓ Branch 0 taken 19744 times.
✓ Branch 1 taken 1234 times.
20978 for(size_t q = 0; q < beamoffs_max; ++q)
23334 19744 puttile16(cbmp, tile+q, q*16, 0, cs, 0);
23335 }
23336 14283 return cbmp;
23337 }
23338
23339 2513808 static int32_t get_beamoffs(spot_t val)
23340 {
23341
12/17
✗ Branch 0 not taken.
✓ Branch 1 taken 2444313 times.
✓ Branch 2 taken 1469 times.
✓ Branch 3 taken 1188 times.
✓ Branch 4 taken 1795 times.
✓ Branch 5 taken 1768 times.
✓ Branch 6 taken 14821 times.
✓ Branch 7 taken 31678 times.
✓ Branch 8 taken 4877 times.
✓ Branch 9 taken 3412 times.
✓ Branch 10 taken 4161 times.
✓ Branch 11 taken 3791 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 535 times.
2513808 switch((val&SP_MASK)>>1)
23342 {
23343 2444313 case 0: default:
23344
2/2
✓ Branch 0 taken 7620 times.
✓ Branch 1 taken 2436693 times.
2444313 if(val)
23345 7620 return beamoffs_gr;
23346 2436693 return -1;
23347 case 0b0001:
23348 1469 return beamoffs_up;
23349 case 0b0010:
23350 1188 return beamoffs_down;
23351 case 0b0100:
23352 1795 return beamoffs_left;
23353 case 0b1000:
23354 1768 return beamoffs_right;
23355 case 0b0011:
23356 14821 return beamoffs_vert;
23357 case 0b1100:
23358 31678 return beamoffs_horz;
23359 case 0b0101:
23360 4877 return beamoffs_uleft;
23361 case 0b1001:
23362 3412 return beamoffs_uright;
23363 case 0b0110:
23364 4161 return beamoffs_dleft;
23365 case 0b1010:
23366 3791 return beamoffs_dright;
23367 case 0b1110:
23368 return beamoffs_notup;
23369 case 0b1101:
23370 return beamoffs_notdown;
23371 case 0b1011:
23372 return beamoffs_notleft;
23373 case 0b0111:
23374 return beamoffs_notright;
23375 case 0b1111:
23376 535 return beamoffs_all;
23377 }
23378 return -1;
23379 2513808 }
23380
23381 14162639 void HeroClass::handleSpotlights()
23382 {
23383 static bool had_spotlight = true;
23384 14162639 word c = tmpscr->numFFC();
23385
2/2
✓ Branch 0 taken 14148356 times.
✓ Branch 1 taken 14283 times.
14162639 if(cpos_exists_spotlight())
23386 {
23387 //Store each different tile/color as grids
23388 14283 std::map<int32_t, spot_t*> maps;
23389 14283 std::map<int32_t, std::map<dword, spot_t>> ffmaps;
23390
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 int32_t shieldid = getCurrentShield(false);
23391
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14283 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14283 if((itemsbuf[shieldid].flags & ITEM_FLAG9) && !usingActiveShield(shieldid))
23392 shieldid = -1;
23393
2/2
✓ Branch 0 taken 10892 times.
✓ Branch 1 taken 3391 times.
14283 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & shLIGHTBEAM);
23394
3/4
✓ Branch 0 taken 3391 times.
✓ Branch 1 taken 10892 times.
✓ Branch 2 taken 3391 times.
✗ Branch 3 not taken.
14283 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & shLIGHTBEAM);
23395
3/6
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14283 times.
✗ Branch 5 not taken.
14283 heropos = COMBOPOS_B(x.getInt()+8,y.getInt()+8);
23396 14283 memset(istrig, 0, sizeof(istrig));
23397
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 clear_bitmap(lightbeam_bmp);
23398
23399
2/2
✓ Branch 0 taken 2513808 times.
✓ Branch 1 taken 14283 times.
2528091 for(size_t pos = 0; pos < 176; ++pos)
23400 {
23401 2513808 typeMap[pos] = 0;
23402 2513808 customTypeMap[pos] = -1;
23403
2/2
✓ Branch 0 taken 2334689 times.
✓ Branch 1 taken 17592933 times.
19927622 for(int32_t lyr = 6; lyr > -1; --lyr)
23404 {
23405 17592933 auto cid = FFCore.tempScreens[lyr]->data[pos];
23406 17592933 newcombo const* cmb = &combobuf[cid];
23407
3/4
✓ Branch 0 taken 17413814 times.
✓ Branch 1 taken 175417 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3702 times.
17592933 switch(cmb->type)
23408 {
23409 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
23410 case cMAGICPRISM: case cMAGICPRISM4:
23411 case cBLOCKALL: case cLIGHTTARGET:
23412 175417 typeMap[pos] = cmb->type;
23413 175417 break;
23414 case cMIRRORNEW:
23415 typeMap[pos] = cMIRRORNEW;
23416 customTypeMap[pos] = cid;
23417 break;
23418 case cGLASS:
23419 3702 typeMap[pos] = 0;
23420 3702 break;
23421 default:
23422 {
23423
4/4
✓ Branch 0 taken 7358582 times.
✓ Branch 1 taken 10055232 times.
✓ Branch 2 taken 1341537 times.
✓ Branch 3 taken 6017045 times.
17413814 if(lyr < 3 && (cmb->walk & 0xF))
23424 {
23425 1341537 typeMap[pos] = SPTYPE_SOLID;
23426 1341537 }
23427 17413814 continue; //next layer
23428 }
23429 }
23430 179119 break; //hit a combo type
23431 }
23432
4/4
✓ Branch 0 taken 2296624 times.
✓ Branch 1 taken 217184 times.
✓ Branch 2 taken 1421859 times.
✓ Branch 3 taken 874765 times.
2513808 if(!get_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ) && !typeMap[pos])
23433 {
23434
8/16
✓ Branch 0 taken 874765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 874765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 874765 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 874765 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 874765 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 874765 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 874765 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 874765 times.
✗ Branch 15 not taken.
874765 if(collide_object(COMBOX(pos),COMBOY(pos),16,16,this))
23435 typeMap[pos] = SPTYPE_SOLID;
23436 874765 }
23437 2513808 }
23438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14283 times.
14283 if(unsigned(heropos) < 176)
23439 {
23440
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14031 times.
14283 switch(typeMap[heropos])
23441 {
23442 case SPTYPE_SOLID: case cBLOCKALL:
23443 252 heropos = -1; //Blocked from hitting player
23444 252 }
23445 14283 }
23446
23447
2/2
✓ Branch 0 taken 99981 times.
✓ Branch 1 taken 14283 times.
114264 for(size_t layer = 0; layer < 7; ++layer)
23448 {
23449 99981 mapscr* curlayer = FFCore.tempScreens[layer];
23450
2/2
✓ Branch 0 taken 17596656 times.
✓ Branch 1 taken 99981 times.
17696637 for(size_t pos = 0; pos < 176; ++pos)
23451 {
23452 17596656 newcombo const& cmb = combobuf[curlayer->data[pos]];
23453
2/2
✓ Branch 0 taken 17582373 times.
✓ Branch 1 taken 14283 times.
17596656 if(cmb.type == cSPOTLIGHT)
23454
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 launch_lightbeam(cmb,pos,maps,refl,block);
23455 17596656 }
23456 99981 }
23457
2/2
✓ Branch 0 taken 16751 times.
✓ Branch 1 taken 14283 times.
31034 for(word i=0; i<c; i++)
23458 {
23459 16751 ffcdata& ffc = tmpscr->ffcs[i];
23460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16751 times.
16751 if(ffc.flags & (ffCHANGER|ffETHEREAL))
23461 continue;
23462 16751 newcombo const& cmb = combobuf[ffc.data];
23463
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16751 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16751 if(cmb.type == cSPOTLIGHT && (cmb.usrflags&cflag2))
23464 launch_fflightbeam(ffc,ffmaps,refl,block);
23465 16751 }
23466
23467
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 lightbeam_present = !maps.empty() || !ffmaps.empty();
23468
23469 //Draw visuals
23470
2/2
✓ Branch 0 taken 14283 times.
✓ Branch 1 taken 14283 times.
28566 for(auto it = maps.begin(); it != maps.end();)
23471 {
23472 14283 int32_t id = it->first;
23473 14283 spot_t* grid = it->second;
23474
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 BITMAP* cbmp = generate_beam_bitmap(id);
23475
2/2
✓ Branch 0 taken 14283 times.
✓ Branch 1 taken 2513808 times.
2528091 for(size_t pos = 0; pos < 176; ++pos)
23476 {
23477
1/2
✓ Branch 0 taken 2513808 times.
✗ Branch 1 not taken.
2513808 int32_t offs = get_beamoffs(grid[pos]);
23478
2/2
✓ Branch 0 taken 77115 times.
✓ Branch 1 taken 2436693 times.
2513808 if(offs > -1)
23479
3/6
✓ Branch 0 taken 77115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77115 times.
✗ Branch 5 not taken.
77115 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, COMBOX(pos), COMBOY(pos), 16, 16);
23480 2513808 }
23481
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 destroy_bitmap(cbmp);
23482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14283 times.
14283 delete[] it->second;
23483
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 it = maps.erase(it);
23484 }
23485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14283 times.
14283 for(auto it = ffmaps.begin(); it != ffmaps.end();)
23486 {
23487 int32_t id = it->first;
23488 std::map<dword,spot_t> const& grid = it->second;
23489 BITMAP* cbmp = generate_beam_bitmap(id);
23490 for(auto it2 = grid.begin(); it2 != grid.end(); ++it2)
23491 {
23492 lightbeam_xy ffxy(it2->first);
23493 int32_t offs = get_beamoffs(it2->second);
23494 if(offs > -1)
23495 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, ffxy.x-8, ffxy.y-8, 16, 16);
23496 }
23497 destroy_bitmap(cbmp);
23498 it = ffmaps.erase(it);
23499 }
23500 14283 }
23501 else
23502 {
23503
2/2
✓ Branch 0 taken 14148091 times.
✓ Branch 1 taken 265 times.
14148356 if(had_spotlight)
23504 {
23505 265 memset(istrig, 0, sizeof(istrig));
23506 265 clear_bitmap(lightbeam_bmp);
23507 265 }
23508 14148356 lightbeam_present = false;
23509 }
23510 14162639 had_spotlight = lightbeam_present;
23511 //Check triggers
23512 14162639 bool hastrigs = false, istrigged = true;
23513 14162639 bool alltrig = getmapflag(mLIGHTBEAM);
23514
2/2
✓ Branch 0 taken 99138473 times.
✓ Branch 1 taken 14162639 times.
113301112 for(size_t layer = 0; layer < 7; ++layer)
23515 {
23516 99138473 mapscr* curlayer = FFCore.tempScreens[layer];
23517
2/2
✓ Branch 0 taken 17448371248 times.
✓ Branch 1 taken 99138473 times.
17547509721 for(size_t pos = 0; pos < 176; ++pos)
23518 {
23519 17448371248 newcombo const* cmb = &combobuf[curlayer->data[pos]];
23520
2/2
✓ Branch 0 taken 13121 times.
✓ Branch 1 taken 17448358127 times.
17448371248 if(cmb->type == cLIGHTTARGET)
23521 {
23522
2/2
✓ Branch 0 taken 11887 times.
✓ Branch 1 taken 1234 times.
13121 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
23523 13121 hastrigs = true;
23524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13121 times.
13121 bool trigged = lightbeam_present && (istrig[pos]&trigflag);
23525
1/2
✓ Branch 0 taken 13121 times.
✗ Branch 1 not taken.
13121 if(cmb->usrflags&cflag2) //Invert
23526 trigged = !trigged;
23527
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 12872 times.
13121 if(cmb->usrflags&cflag1) //Solved Version
23528 {
23529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
23530 {
23531 curlayer->data[pos] -= 1;
23532 istrigged = false;
23533 }
23534 249 }
23535 else //Unsolved version
23536 {
23537
3/4
✓ Branch 0 taken 12872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 12868 times.
12872 if(alltrig || trigged) //Light
23538 4 curlayer->data[pos] += 1;
23539 12868 else istrigged = false;
23540 }
23541 13121 }
23542
2/2
✓ Branch 0 taken 17448354425 times.
✓ Branch 1 taken 3702 times.
17448358127 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
23543 {
23544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
3702 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
23545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
3702 bool trigged = lightbeam_present && (istrig[pos]&trigflag);
23546
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 3597 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 3696 times.
3702 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
23547 3597 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
23548 {
23549 6 do_trigger_combo(layer, pos);
23550 6 }
23551 3702 }
23552 17448371248 }
23553 99138473 }
23554
2/2
✓ Branch 0 taken 424031367 times.
✓ Branch 1 taken 14162639 times.
438194006 for(word i=0; i<c; i++)
23555 {
23556 424031367 ffcdata& ffc = tmpscr->ffcs[i];
23557 424031367 newcombo const* cmb = &combobuf[ffc.data];
23558
2/2
✓ Branch 0 taken 423053793 times.
✓ Branch 1 taken 977574 times.
424031367 size_t pos = get_qr(qr_BROKEN_LIGHTBEAM_HITBOX)
23559 423053793 ? COMBOPOS(ffc.x+8, ffc.y+8)
23560 977574 : COMBOPOS(ffc.x+(ffc.hit_width/2), ffc.y+(ffc.hit_height/2));
23561
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 424030133 times.
424031367 if(cmb->type == cLIGHTTARGET)
23562 {
23563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
23564 1234 hastrigs = true;
23565 1234 bool trigged = (istrig[pos]&trigflag);
23566
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb->usrflags&cflag2) //Invert
23567 trigged = !trigged;
23568
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 985 times.
1234 if(cmb->usrflags&cflag1) //Solved Version
23569 {
23570
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
23571 {
23572 zc_ffc_modify(ffc, -1);
23573 istrigged = false;
23574 }
23575 249 }
23576 else //Unsolved version
23577 {
23578
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
23579 1 zc_ffc_modify(ffc, 1);
23580 984 else istrigged = false;
23581 }
23582 1234 }
23583
2/2
✓ Branch 0 taken 424027665 times.
✓ Branch 1 taken 2468 times.
424030133 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
23584 {
23585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2468 times.
2468 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
23586 2468 bool trigged = (istrig[pos]&trigflag);
23587
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2406 times.
✓ Branch 2 taken 2464 times.
✓ Branch 3 taken 4 times.
2468 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
23588 2406 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
23589 {
23590 4 do_trigger_combo_ffc(i);
23591 4 }
23592 2468 }
23593 424031367 }
23594
6/6
✓ Branch 0 taken 13121 times.
✓ Branch 1 taken 14149518 times.
✓ Branch 2 taken 253 times.
✓ Branch 3 taken 12868 times.
✓ Branch 4 taken 249 times.
✓ Branch 5 taken 4 times.
14162639 if(hastrigs && istrigged && !alltrig)
23595 {
23596 4 hidden_entrance(0,true,false,-7);
23597 4 sfx(tmpscr->secretsfx);
23598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!(tmpscr->flags5&fTEMPSECRETS))
23599 {
23600 4 setmapflag(mSECRET);
23601 4 setmapflag(mLIGHTBEAM);
23602 4 }
23603 4 }
23604 14162639 }
23605
23606 14140122 void HeroClass::checktouchblk()
23607 {
23608
2/2
✓ Branch 0 taken 14694 times.
✓ Branch 1 taken 14125428 times.
14140122 if(toogam) return;
23609
23610
2/2
✓ Branch 0 taken 946808 times.
✓ Branch 1 taken 13178620 times.
14125428 if(!pushing)
23611 13178620 return;
23612
23613 946808 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
23614
23615
4/4
✓ Branch 0 taken 938032 times.
✓ Branch 1 taken 8776 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 937936 times.
946808 if(charging > 0 || spins > 0) //if not I probably will at some point...
23616 {
23617
4/4
✓ Branch 0 taken 4072 times.
✓ Branch 1 taken 4800 times.
✓ Branch 2 taken 2940 times.
✓ Branch 3 taken 1132 times.
8872 if(Up()&&Left())tdir = (charging%2)*2;
23618
4/4
✓ Branch 0 taken 2940 times.
✓ Branch 1 taken 4800 times.
✓ Branch 2 taken 1410 times.
✓ Branch 3 taken 1530 times.
7740 else if(Up()&&Right())tdir = (charging%2)*3;
23619
4/4
✓ Branch 0 taken 2544 times.
✓ Branch 1 taken 3666 times.
✓ Branch 2 taken 1681 times.
✓ Branch 3 taken 863 times.
6210 else if(Down()&&Left())tdir = 1+(charging%2)*1;
23620
4/4
✓ Branch 0 taken 1681 times.
✓ Branch 1 taken 3666 times.
✓ Branch 2 taken 869 times.
✓ Branch 3 taken 812 times.
5347 else if(Down()&&Right())tdir = 1+(charging%2)*2;
23621 else
23622 {
23623
2/2
✓ Branch 0 taken 1410 times.
✓ Branch 1 taken 3125 times.
4535 if(Up())tdir=0;
23624
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 2261 times.
3125 else if(Down())tdir=1;
23625
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 1382 times.
2261 else if(Left())tdir=2;
23626
1/2
✓ Branch 0 taken 1382 times.
✗ Branch 1 not taken.
1382 else if(Right())tdir=3;
23627 }
23628 8872 }
23629
23630 946808 int32_t tx=0,ty=-1;
23631
23632
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 234263 times.
✓ Branch 2 taken 212245 times.
✓ Branch 3 taken 233309 times.
✓ Branch 4 taken 266991 times.
946808 switch(tdir)
23633 {
23634 case up:
23635
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 234042 times.
234263 if(touchcombo(x,y+(bigHitbox?0:7)))
23636 {
23637 221 tx=x;
23638 221 ty=y+(bigHitbox?0:7);
23639 221 }
23640
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 234017 times.
234042 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
23641 {
23642 25 tx=x+8;
23643 25 ty=y+(bigHitbox?0:7);
23644 25 }
23645
23646 234263 break;
23647
23648 case down:
23649
2/2
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 210596 times.
212245 if(touchcombo(x,y+16))
23650 {
23651 1649 tx=x;
23652 1649 ty=y+16;
23653 1649 }
23654
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 210332 times.
210596 else if(touchcombo(x+8,y+16))
23655 {
23656 264 tx=x+8;
23657 264 ty=y+16;
23658 264 }
23659
23660 212245 break;
23661
23662 case left:
23663
2/2
✓ Branch 0 taken 232468 times.
✓ Branch 1 taken 841 times.
233309 if(touchcombo(x-1,y+15))
23664 {
23665 841 tx=x-1;
23666 841 ty=y+15;
23667 841 }
23668
23669 233309 break;
23670
23671 case right:
23672
2/2
✓ Branch 0 taken 265809 times.
✓ Branch 1 taken 1182 times.
266991 if(touchcombo(x+16,y+15))
23673 {
23674 1182 tx=x+16;
23675 1182 ty=y+15;
23676 1182 }
23677
23678 266991 break;
23679 }
23680
23681
2/2
✓ Branch 0 taken 942626 times.
✓ Branch 1 taken 4182 times.
946808 if(ty>=0)
23682 {
23683 4182 ty&=0xF0;
23684 4182 tx&=0xF0;
23685 4182 int32_t di = ty+(tx>>4);
23686
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4182 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4182 if((getAction() != hopping || isSideViewHero()))
23687 {
23688 4182 trigger_armos_grave(0, di, dir);
23689 4182 }
23690 4182 }
23691 14140122 }
23692
23693 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
23694 {
23695 switch(cdir)
23696 {
23697 case up:
23698 cy-=16;
23699 break;
23700
23701 case down:
23702 cy+=16;
23703 break;
23704
23705 case left:
23706 cx-=16;
23707 break;
23708
23709 case right:
23710 cx+=16;
23711 break;
23712 }
23713
23714 // off the screen
23715 if(cx<0 || cy<0 || cx>255 || cy>175)
23716 {
23717 int ns;
23718 if(auto scr = nextscr(cdir,false))
23719 ns = *scr;
23720 else return 0;
23721
23722 switch(cdir)
23723 {
23724 case up:
23725 cy=160;
23726 break;
23727
23728 case down:
23729 cy=0;
23730 break;
23731
23732 case left:
23733 cx=240;
23734 break;
23735
23736 case right:
23737 cx=0;
23738 break;
23739 }
23740
23741 // from MAPCOMBO()
23742 int32_t cmb = (cy&0xF0)+(cx>>4);
23743
23744 if(cmb>175)
23745 return 0;
23746
23747 return TheMaps[ns].data[cmb]; // entire combo code
23748 }
23749
23750 return MAPCOMBO(cx,cy);
23751 }
23752
23753 15867 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
23754 {
23755
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 3545 times.
✓ Branch 3 taken 3978 times.
✓ Branch 4 taken 5141 times.
15867 switch(cdir)
23756 {
23757 case up:
23758 3203 cy-=16;
23759 3203 break;
23760
23761 case down:
23762 3545 cy+=16;
23763 3545 break;
23764
23765 case left:
23766 3978 cx-=16;
23767 3978 break;
23768
23769 case right:
23770 5141 cx+=16;
23771 5141 break;
23772 }
23773
23774 // off the screen
23775
8/8
✓ Branch 0 taken 15766 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 15621 times.
✓ Branch 3 taken 145 times.
✓ Branch 4 taken 15447 times.
✓ Branch 5 taken 174 times.
✓ Branch 6 taken 192 times.
✓ Branch 7 taken 15255 times.
15867 if(cx<0 || cy<0 || cx>255 || cy>175)
23776 {
23777 int ns;
23778
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 4 times.
612 if(auto scr = nextscr(cdir,false))
23779 608 ns = *scr;
23780 4 else return 0;
23781
23782
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 101 times.
✓ Branch 4 taken 174 times.
608 switch(cdir)
23783 {
23784 case up:
23785 143 cy=160;
23786 143 break;
23787
23788 case down:
23789 190 cy=0;
23790 190 break;
23791
23792 case left:
23793 101 cx=240;
23794 101 break;
23795
23796 case right:
23797 174 cx=0;
23798 174 break;
23799 }
23800
23801 // from MAPCOMBO()
23802 608 int32_t cmb = (cy&0xF0)+(cx>>4);
23803
23804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 608 times.
608 if(cmb>175)
23805 return 0;
23806
23807
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 523 times.
608 if(!comboflag)
23808 {
23809 523 return TheMaps[ns].sflag[cmb]; // flag
23810 }
23811 else
23812 {
23813 85 return combobuf[TheMaps[ns].data[cmb]].flag; // flag
23814 }
23815 }
23816
23817
2/2
✓ Branch 0 taken 3952 times.
✓ Branch 1 taken 11303 times.
15255 if(comboflag)
23818 {
23819 3952 return MAPCOMBOFLAG(cx,cy);
23820 }
23821
23822 11303 return MAPFLAG(cx,cy);
23823 15867 }
23824
23825 bool did_secret;
23826
23827 14140122 void HeroClass::checkspecial()
23828 {
23829 14140122 checktouchblk();
23830
23831 14140122 bool hasmainguy = hasMainGuy(); // calculate it once
23832
23833
4/4
✓ Branch 0 taken 14019599 times.
✓ Branch 1 taken 120523 times.
✓ Branch 2 taken 8588023 times.
✓ Branch 3 taken 5431576 times.
14140122 if(!(loaded_enemies && !hasmainguy))
23834 8708546 did_secret=false;
23835 else
23836 {
23837 // after beating enemies
23838
23839 // generic 'Enemies->' trigger
23840
2/2
✓ Branch 0 taken 38021032 times.
✓ Branch 1 taken 5431576 times.
43452608 for(auto lyr = 0; lyr < 7; ++lyr)
23841 {
23842
2/2
✓ Branch 0 taken 6691701632 times.
✓ Branch 1 taken 38021032 times.
6729722664 for(auto pos = 0; pos < 176; ++pos)
23843 {
23844 6691701632 newcombo const& cmb = combobuf[FFCore.tempScreens[lyr]->data[pos]];
23845
2/2
✓ Branch 0 taken 6691701627 times.
✓ Branch 1 taken 5 times.
6691701632 if(cmb.triggerflags[2] & combotriggerENEMIESKILLED)
23846 {
23847 5 do_trigger_combo(lyr,pos);
23848 5 }
23849 6691701632 }
23850 38021032 }
23851 5431576 word c = tmpscr->numFFC();
23852
2/2
✓ Branch 0 taken 157832816 times.
✓ Branch 1 taken 5431576 times.
163264392 for(word i=0; i<c; i++)
23853 {
23854 157832816 ffcdata& ffc = tmpscr->ffcs[i];
23855 157832816 newcombo const& cmb = combobuf[ffc.data];
23856
1/2
✓ Branch 0 taken 157832816 times.
✗ Branch 1 not taken.
157832816 if(cmb.triggerflags[2] & combotriggerENEMIESKILLED)
23857 {
23858 do_trigger_combo_ffc(i);
23859 }
23860 157832816 }
23861
1/2
✓ Branch 0 taken 5431576 times.
✗ Branch 1 not taken.
5431576 if(tmpscr->flags9 & fENEMY_WAVES)
23862 {
23863 hasmainguy = hasMainGuy(); //possibly un-beat the enemies (another 'wave'?)
23864 }
23865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5431576 times.
5431576 if(!hasmainguy)
23866 {
23867 // item
23868
2/2
✓ Branch 0 taken 5430828 times.
✓ Branch 1 taken 748 times.
5431576 if(hasitem&(4|2|1))
23869 {
23870 748 int32_t Item=tmpscr->item;
23871
23872 //if(getmapflag())
23873 // Item=0;
23874
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 748 times.
748 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
23875 {
23876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 748 times.
748 if(hasitem==1)
23877 748 sfx(WAV_CLEARED);
23878
23879
2/4
✓ Branch 0 taken 748 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 748 times.
✗ Branch 3 not taken.
1496 items.add(new item((zfix)tmpscr->itemx,
23880
6/12
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 677 times.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 71 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 748 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 748 times.
✗ Branch 11 not taken.
748 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
23881
6/10
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 677 times.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 71 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 677 times.
✗ Branch 9 not taken.
748 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
23882
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 747 times.
748 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
23883 748 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
23884 748 }
23885
23886 748 hasitem &= ~ (4|2|1);
23887 748 }
23888 // if room has traps, guys don't come back
23889
2/2
✓ Branch 0 taken 2780966912 times.
✓ Branch 1 taken 5431576 times.
2786398488 for(int32_t i=0; i<eMAXGUYS; i++)
23890 {
23891
4/4
✓ Branch 0 taken 81048311 times.
✓ Branch 1 taken 2699918601 times.
✓ Branch 2 taken 70242365 times.
✓ Branch 3 taken 10805946 times.
2780966912 if(guysbuf[i].family==eeTRAP&&guysbuf[i].misc2)
23892
4/4
✓ Branch 0 taken 79095 times.
✓ Branch 1 taken 10726851 times.
✓ Branch 2 taken 78998 times.
✓ Branch 3 taken 97 times.
10806043 if(guys.idCount(i) && !getmapflag(mTMPNORET))
23893 97 setmapflag(mTMPNORET);
23894 2780966912 }
23895 // clear enemies and open secret
23896
4/4
✓ Branch 0 taken 5240662 times.
✓ Branch 1 taken 190914 times.
✓ Branch 2 taken 5239812 times.
✓ Branch 3 taken 850 times.
5431576 if(!did_secret && (tmpscr->flags2&fCLEARSECRET))
23897 {
23898 850 bool only16_31 = get_qr(qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
23899 850 hidden_entrance(0,true,only16_31,-2);
23900
23901
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 745 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 100 times.
850 if(tmpscr->flags4&fENEMYSCRTPERM && canPermSecret())
23902 {
23903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
23904 100 }
23905
23906 850 sfx(tmpscr->secretsfx);
23907 850 did_secret=true;
23908 850 }
23909 5431576 }
23910 }
23911
23912 // doors
23913 14140122 bool has_shutter = false;
23914
2/2
✓ Branch 0 taken 12108228 times.
✓ Branch 1 taken 52918158 times.
65026386 for(int32_t i=0; i<4; i++)
23915
2/2
✓ Branch 0 taken 50886264 times.
✓ Branch 1 taken 2031894 times.
52918158 if(tmpscr->door[i]==dSHUTTER)
23916 {
23917 2031894 has_shutter = true;
23918
4/4
✓ Branch 0 taken 1991624 times.
✓ Branch 1 taken 40270 times.
✓ Branch 2 taken 1424 times.
✓ Branch 3 taken 1990200 times.
2031894 if(opendoors==0 && loaded_enemies)
23919 {
23920
4/4
✓ Branch 0 taken 1657919 times.
✓ Branch 1 taken 332281 times.
✓ Branch 2 taken 1655495 times.
✓ Branch 3 taken 2424 times.
1990200 if(!(tmpscr->flags&fSHUTTERS) && !hasmainguy)
23921 2424 opendoors=12;
23922 1990200 }
23923
2/2
✓ Branch 0 taken 32972 times.
✓ Branch 1 taken 8722 times.
41694 else if(opendoors<0)
23924 8722 ++opendoors;
23925
2/2
✓ Branch 0 taken 30240 times.
✓ Branch 1 taken 2732 times.
32972 else if((--opendoors)==0)
23926 2732 openshutters();
23927
23928 2031894 break;
23929 }
23930
10/10
✓ Branch 0 taken 12108228 times.
✓ Branch 1 taken 2031894 times.
✓ Branch 2 taken 11872614 times.
✓ Branch 3 taken 235614 times.
✓ Branch 4 taken 11759420 times.
✓ Branch 5 taken 113194 times.
✓ Branch 6 taken 11686900 times.
✓ Branch 7 taken 72520 times.
✓ Branch 8 taken 6577593 times.
✓ Branch 9 taken 5109307 times.
14140122 if(!has_shutter && !opendoors && loaded_enemies && !(tmpscr->flags&fSHUTTERS) && !hasmainguy)
23931 {
23932 5109307 openshutters();
23933 5109307 }
23934
23935 // set boss flag when boss is gone
23936
6/6
✓ Branch 0 taken 14019599 times.
✓ Branch 1 taken 120523 times.
✓ Branch 2 taken 204006 times.
✓ Branch 3 taken 13815593 times.
✓ Branch 4 taken 153974 times.
✓ Branch 5 taken 50032 times.
14140122 if(loaded_enemies && tmpscr->enemyflags&efBOSS && !hasmainguy)
23937 {
23938 50032 game->lvlitems[dlevel]|=liBOSS;
23939 50032 stop_sfx(tmpscr->bosssfx);
23940 50032 }
23941
23942
2/2
✓ Branch 0 taken 14063826 times.
✓ Branch 1 taken 76296 times.
14140122 if(getmapflag(mCHEST)) // if special stuff done before
23943 {
23944 76296 remove_chests((currscr>=128)?1:0);
23945 76296 }
23946
23947
2/2
✓ Branch 0 taken 14137662 times.
✓ Branch 1 taken 2460 times.
14140122 if(getmapflag(mLOCKEDCHEST)) // if special stuff done before
23948 {
23949 2460 remove_lockedchests((currscr>=128)?1:0);
23950 2460 }
23951
23952
2/2
✓ Branch 0 taken 14113921 times.
✓ Branch 1 taken 26201 times.
14140122 if(getmapflag(mBOSSCHEST)) // if special stuff done before
23953 {
23954 26201 remove_bosschests((currscr>=128)?1:0);
23955 26201 }
23956
23957 14140122 clear_xdoors((currscr>=128)?1:0);
23958 14140122 clear_xstatecombos((currscr>=128)?1:0);
23959
23960
4/4
✓ Branch 0 taken 34468 times.
✓ Branch 1 taken 14105654 times.
✓ Branch 2 taken 34438 times.
✓ Branch 3 taken 30 times.
14140122 if((hasitem&8) && triggered_screen_secrets)
23961 {
23962 30 int32_t Item=tmpscr->item;
23963
23964
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 24 times.
30 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
23965 {
23966
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
48 items.add(new item((zfix)tmpscr->itemx,
23967
6/12
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 24 times.
✗ Branch 11 not taken.
24 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
23968
6/10
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
24 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
23969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
23970 24 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
23971 24 }
23972
23973 30 hasitem &= ~8;
23974 30 }
23975 14140122 }
23976
23977 //Gets the 4 comboposes indicated by the coordinates, replacing duplicates with '-1'
23978 13386054 void getPoses(int32_t* poses, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
23979 {
23980 int32_t tmp;
23981 13386054 poses[0] = COMBOPOS(x1,y1);
23982
23983 13386054 tmp = COMBOPOS(x1,y2);
23984
2/2
✓ Branch 0 taken 9701452 times.
✓ Branch 1 taken 3684602 times.
13386054 if(tmp == poses[0])
23985 9701452 poses[1] = -1;
23986 3684602 else poses[1] = tmp;
23987
23988 13386054 tmp = COMBOPOS(x2,y1);
23989
3/4
✓ Branch 0 taken 6474690 times.
✓ Branch 1 taken 6911364 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6474690 times.
13386054 if(tmp == poses[0] || tmp == poses[1])
23990 6911364 poses[2] = -1;
23991 6474690 else poses[2] = tmp;
23992
23993 13386054 tmp = COMBOPOS(x2,y2);
23994
6/6
✓ Branch 0 taken 8411387 times.
✓ Branch 1 taken 4974667 times.
✓ Branch 2 taken 6474690 times.
✓ Branch 3 taken 1936697 times.
✓ Branch 4 taken 4726785 times.
✓ Branch 5 taken 1747905 times.
13386054 if(tmp == poses[0] || tmp == poses[1] || tmp == poses[2])
23995 11638149 poses[3] = -1;
23996 1747905 else poses[3] = tmp;
23997 13386054 }
23998
23999 14102250 void HeroClass::checkspecial2(int32_t *ls)
24000 {
24001
6/8
✓ Branch 0 taken 9971619 times.
✓ Branch 1 taken 4130631 times.
✓ Branch 2 taken 9715685 times.
✓ Branch 3 taken 255934 times.
✓ Branch 4 taken 9715685 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9715685 times.
14102250 if(get_qr(qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
24002 {
24003 // Must run fairycircle stuff if currently active, otherwise hero gets stuck!
24004
2/2
✓ Branch 0 taken 21923 times.
✓ Branch 1 taken 9693762 times.
9715685 if (!fairyclk)
24005 {
24006
2/2
✓ Branch 0 taken 2921612 times.
✓ Branch 1 taken 6772150 times.
9693762 if(y.getInt()&7)
24007 2921612 return;
24008
24009
2/2
✓ Branch 0 taken 3818046 times.
✓ Branch 1 taken 2954104 times.
6772150 if(x.getInt()&7)
24010 3818046 return;
24011 2954104 }
24012 2976027 }
24013
24014
2/2
✓ Branch 0 taken 5800 times.
✓ Branch 1 taken 7356792 times.
7362592 if(toogam) return;
24015
24016 7356792 bool didstrig = false;
24017
24018
2/2
✓ Branch 0 taken 14694742 times.
✓ Branch 1 taken 7356752 times.
22051494 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
24019 {
24020
4/4
✓ Branch 0 taken 29389455 times.
✓ Branch 1 taken 14694702 times.
✓ Branch 2 taken 58778870 times.
✓ Branch 3 taken 29389415 times.
102862987 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
24021 {
24022
2/2
✓ Branch 0 taken 29389415 times.
✓ Branch 1 taken 29389455 times.
58778870 newcombo const& cmb = combobuf[k>0 ? MAPFFCOMBO(x+j,y+i) : MAPCOMBO(x+j,y+i)];
24023 58778870 int32_t stype = cmb.type;
24024 58778870 int32_t warpsound = cmb.attribytes[0];
24025
2/2
✓ Branch 0 taken 58778668 times.
✓ Branch 1 taken 202 times.
58778870 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
24026 202 stype = cNONE;
24027
2/2
✓ Branch 0 taken 58778836 times.
✓ Branch 1 taken 34 times.
58778870 if(stype==cSWARPA)
24028 {
24029
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1 times.
34 if(tmpscr->flags5&fDIRECTSWARP)
24030 {
24031 1 didpit=true;
24032 1 pitx=x;
24033 1 pity=y;
24034 1 }
24035
24036 34 sdir=dir;
24037 34 dowarp(0,0,warpsound);
24038 34 return;
24039 }
24040
24041
2/2
✓ Branch 0 taken 58778831 times.
✓ Branch 1 taken 5 times.
58778836 if(stype==cSWARPB)
24042 {
24043
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tmpscr->flags5&fDIRECTSWARP)
24044 {
24045 didpit=true;
24046 pitx=x;
24047 pity=y;
24048 }
24049
24050 5 sdir=dir;
24051 5 dowarp(0,1,warpsound);
24052 5 return;
24053 }
24054
24055
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 58778830 times.
58778831 if(stype==cSWARPC)
24056 {
24057
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags5&fDIRECTSWARP)
24058 {
24059 didpit=true;
24060 pitx=x;
24061 pity=y;
24062 }
24063
24064 1 sdir=dir;
24065 1 dowarp(0,2,warpsound);
24066 1 return;
24067 }
24068
24069
1/2
✓ Branch 0 taken 58778830 times.
✗ Branch 1 not taken.
58778830 if(stype==cSWARPD)
24070 {
24071 if(tmpscr->flags5&fDIRECTSWARP)
24072 {
24073 didpit=true;
24074 pitx=x;
24075 pity=y;
24076 }
24077
24078 sdir=dir;
24079 dowarp(0,3,warpsound);
24080 return;
24081 }
24082
24083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58778830 times.
58778830 if(stype==cSWARPR)
24084 {
24085 if(tmpscr->flags5&fDIRECTSWARP)
24086 {
24087 didpit=true;
24088 pitx=x;
24089 pity=y;
24090 }
24091
24092 sdir=dir;
24093 dowarp(0,(zc_oldrand()%4),warpsound);
24094 return;
24095 }
24096
24097 58778830 int32_t pos = COMBOPOS(x+j, y+i);
24098
4/4
✓ Branch 0 taken 58774680 times.
✓ Branch 1 taken 4150 times.
✓ Branch 2 taken 58776351 times.
✓ Branch 3 taken 2479 times.
58778830 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=pos)
24099 {
24100 // zprint("Step Secs\n");
24101
3/4
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 1584 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 895 times.
2479 if(stype==cSTRIGFLAG && canPermSecret())
24102 {
24103
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 603 times.
895 if(!didstrig)
24104 {
24105 603 stepsecret = pos;
24106
24107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603 times.
603 if(!(tmpscr->flags5&fTEMPSECRETS))
24108 {
24109 603 setmapflag(mSECRET);
24110 603 }
24111 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
24112 //zprint("Step Secrets SFX: %d\n", thesfx);
24113 603 sfx(warpsound,pan((int32_t)x));
24114 603 hidden_entrance(0,true,false);
24115 603 didstrig = true;
24116 603 }
24117 895 }
24118 else
24119 {
24120
2/2
✓ Branch 0 taken 680 times.
✓ Branch 1 taken 904 times.
1584 if(!didstrig)
24121 {
24122 904 stepsecret = pos;
24123 904 bool only16_31 = get_qr(qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
24124 904 hidden_entrance(0,true,only16_31);
24125 904 didstrig = true;
24126 //play trigger sound
24127 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
24128 //zprint("Step Secrets SFX: %d\n", thesfx);
24129 //sfx(thesfx,pan((int32_t)x));
24130 904 sfx(warpsound,pan((int32_t)x));
24131 904 }
24132 }
24133 2479 }
24134 88168245 }
24135 14694702 }
24136
24137 7356752 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
24138
24139 // check if he's standing on a warp he just came out of
24140 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
24141
2/2
✓ Branch 0 taken 2008626 times.
✓ Branch 1 taken 5348126 times.
7356752 if (!get_qr(qr_210_WARPRETURN))
24142 {
24143
6/6
✓ Branch 0 taken 5336763 times.
✓ Branch 1 taken 11363 times.
✓ Branch 2 taken 351408 times.
✓ Branch 3 taken 4985355 times.
✓ Branch 4 taken 54011 times.
✓ Branch 5 taken 297397 times.
5348126 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
24144 {
24145
5/6
✓ Branch 0 taken 296332 times.
✓ Branch 1 taken 1065 times.
✓ Branch 2 taken 294847 times.
✓ Branch 3 taken 1485 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 294847 times.
297397 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
24146 {
24147
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 294842 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
294847 if (get_qr(qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
24148 294847 else return;
24149 }
24150 2550 }
24151 5053279 }
24152 else
24153 {
24154
2/2
✓ Branch 0 taken 1677172 times.
✓ Branch 1 taken 331454 times.
2008626 if((int(y)&0xF8)==warpy)
24155 {
24156
2/2
✓ Branch 0 taken 4076 times.
✓ Branch 1 taken 327378 times.
331454 if(x==warpx)
24157 {
24158
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 327378 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327378 if (get_qr(qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
24159 327378 else return;
24160 }
24161 4076 }
24162 }
24163
2/2
✓ Branch 0 taken 9404 times.
✓ Branch 1 taken 6725123 times.
6734527 if (!RaftPass) warpy=-1;
24164
24165
6/6
✓ Branch 0 taken 6717749 times.
✓ Branch 1 taken 13210 times.
✓ Branch 2 taken 323606 times.
✓ Branch 3 taken 6394143 times.
✓ Branch 4 taken 244739 times.
✓ Branch 5 taken 78867 times.
6734527 if(((int32_t)y<raftwarpy-(get_qr(qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_qr(qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
24166 {
24167 6486220 raftwarpy = -1;
24168 6486220 }
24169
6/6
✓ Branch 0 taken 6719084 times.
✓ Branch 1 taken 11875 times.
✓ Branch 2 taken 311764 times.
✓ Branch 3 taken 6407320 times.
✓ Branch 4 taken 226388 times.
✓ Branch 5 taken 85376 times.
6730959 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
24170 {
24171 6504571 raftwarpx = -1;
24172 6504571 }
24173 6712895 int32_t tx=x;
24174 6712895 int32_t ty=y;
24175
24176 6712895 int32_t flag=0;
24177 6712895 int32_t flag2=0;
24178 6712895 int32_t flag3=0;
24179 6712895 int32_t type=0;
24180 6712895 int32_t water=0;
24181 6712895 int32_t index = 0;
24182
24183 6712895 bool setsave=false;
24184 6712895 int32_t warpsfx2 = 0;
24185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6712895 times.
6712895 if (RaftPass) goto RaftingStuff;
24186
24187 //bool gotpit=false;
24188
24189 int32_t x1,x2,y1,y2;
24190 6712895 x1 = tx;
24191 6712895 x2 = tx+15;
24192 6712895 y1 = ty;
24193 6712895 y2 = ty+15;
24194
24195
5/6
✓ Branch 0 taken 2513744 times.
✓ Branch 1 taken 4199151 times.
✓ Branch 2 taken 2513744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12228 times.
✓ Branch 5 taken 2525972 times.
6712895 if((diagonalMovement||NO_GRIDLOCK))
24196 {
24197 4211379 x1 = tx+4;
24198 4211379 x2 = tx+11;
24199 4211379 y1 = ty+4;
24200 4211379 y2 = ty+11;
24201 4211379 }
24202
24203 int32_t types[4];
24204 6737351 types[0]=types[1]=types[2]=types[3]=-1;
24205 int32_t cids[4];
24206 int32_t ffcids[4];
24207 6737351 cids[0]=cids[1]=cids[2]=cids[3]=-1;
24208 6737351 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
24209 //
24210 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
24211 //
24212 6737351 types[0] = MAPFLAG(x1,y1);
24213 6737351 types[1] = MAPFLAG(x1,y2);
24214 6737351 types[2] = MAPFLAG(x2,y1);
24215 6737351 types[3] = MAPFLAG(x2,y2);
24216
24217
24218 //MAPFFCOMBO
24219
24220
24221
6/6
✓ Branch 0 taken 6506277 times.
✓ Branch 1 taken 231074 times.
✓ Branch 2 taken 6479092 times.
✓ Branch 3 taken 27185 times.
✓ Branch 4 taken 81422 times.
✓ Branch 5 taken 6397670 times.
6737351 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24222 6397670 flag = types[0];
24223 // 2.10 compatibility...
24224
10/10
✓ Branch 0 taken 147941 times.
✓ Branch 1 taken 191740 times.
✓ Branch 2 taken 121851 times.
✓ Branch 3 taken 26090 times.
✓ Branch 4 taken 107986 times.
✓ Branch 5 taken 13865 times.
✓ Branch 6 taken 107890 times.
✓ Branch 7 taken 96 times.
✓ Branch 8 taken 98 times.
✓ Branch 9 taken 107792 times.
339681 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
24225 14059 flag = types[0];
24226
24227
24228 6737351 types[0] = MAPCOMBOFLAG(x1,y1);
24229 6737351 types[1] = MAPCOMBOFLAG(x1,y2);
24230 6737351 types[2] = MAPCOMBOFLAG(x2,y1);
24231 6737351 types[3] = MAPCOMBOFLAG(x2,y2);
24232
24233
6/6
✓ Branch 0 taken 6664564 times.
✓ Branch 1 taken 72787 times.
✓ Branch 2 taken 6657550 times.
✓ Branch 3 taken 7014 times.
✓ Branch 4 taken 17736 times.
✓ Branch 5 taken 6639814 times.
6737351 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24234 6639814 flag2 = types[0];
24235
9/12
✓ Branch 0 taken 20949 times.
✓ Branch 1 taken 76588 times.
✓ Branch 2 taken 3350 times.
✓ Branch 3 taken 17599 times.
✓ Branch 4 taken 2740 times.
✓ Branch 5 taken 610 times.
✓ Branch 6 taken 2740 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2740 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2740 times.
97537 else if(!get_qr(qr_FAIRY_FLAG_COMPAT) && y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
24236 flag2 = types[0];
24237
24238 6737351 types[0] = MAPFFCOMBOFLAG(x1,y1);
24239 6737351 types[1] = MAPFFCOMBOFLAG(x1,y2);
24240 6737351 types[2] = MAPFFCOMBOFLAG(x2,y1);
24241 6737351 types[3] = MAPFFCOMBOFLAG(x2,y2);
24242
24243
24244 //
24245
24246
6/6
✓ Branch 0 taken 6724520 times.
✓ Branch 1 taken 12831 times.
✓ Branch 2 taken 6724373 times.
✓ Branch 3 taken 147 times.
✓ Branch 4 taken 17 times.
✓ Branch 5 taken 6724356 times.
6737351 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24247 6724356 flag3 = types[0];
24248
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 12995 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
12995 else if(!get_qr(qr_FAIRY_FLAG_COMPAT) && y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
24249 flag3 = types[0];
24250
24251 //
24252 // Now, let's check for warp combos...
24253 //
24254
24255 //
24256
24257 6737351 cids[0] = MAPCOMBO(x1,y1);
24258 6737351 cids[1] = MAPCOMBO(x1,y2);
24259 6737351 cids[2] = MAPCOMBO(x2,y1);
24260 6737351 cids[3] = MAPCOMBO(x2,y2);
24261
24262 6737351 types[0] = COMBOTYPE(x1,y1);
24263
24264
2/2
✓ Branch 0 taken 6546025 times.
✓ Branch 1 taken 171644 times.
6737351 if(MAPFFCOMBO(x1,y1))
24265 {
24266 171644 types[0] = FFCOMBOTYPE(x1,y1);
24267 171644 cids[0] = MAPFFCOMBO(x1,y1);
24268 171644 }
24269
24270 6717669 types[1] = COMBOTYPE(x1,y2);
24271
24272
2/2
✓ Branch 0 taken 6590618 times.
✓ Branch 1 taken 127051 times.
6717669 if(MAPFFCOMBO(x1,y2))
24273 {
24274 127051 types[1] = FFCOMBOTYPE(x1,y2);
24275 127051 cids[1] = MAPFFCOMBO(x1,y2);
24276 127051 }
24277
24278 6717669 types[2] = COMBOTYPE(x2,y1);
24279
24280
2/2
✓ Branch 0 taken 6546743 times.
✓ Branch 1 taken 170926 times.
6717669 if(MAPFFCOMBO(x2,y1))
24281 {
24282 170926 types[2] = FFCOMBOTYPE(x2,y1);
24283 170926 cids[2] = MAPFFCOMBO(x2,y1);
24284 170926 }
24285 6717669 types[3] = COMBOTYPE(x2,y2);
24286
24287
2/2
✓ Branch 0 taken 6590150 times.
✓ Branch 1 taken 127519 times.
6717669 if(MAPFFCOMBO(x2,y2))
24288 {
24289 127519 types[3] = FFCOMBOTYPE(x2,y2);
24290 127519 cids[3] = MAPFFCOMBO(x2,y2);
24291 127519 }
24292 // Change B, C and D warps into A, for the comparison below...
24293
2/2
✓ Branch 0 taken 26900492 times.
✓ Branch 1 taken 6717669 times.
33618161 for(int32_t i=0; i<4; i++)
24294 {
24295
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 26900168 times.
26900492 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
24296 {
24297 324 types[i] = cNONE;
24298 324 continue;
24299 }
24300
2/2
✓ Branch 0 taken 6925 times.
✓ Branch 1 taken 26893243 times.
26900168 if(types[i]==cCAVE)
24301 {
24302 6925 index=0;
24303 6925 warpsfx2 = combobuf[cids[i]].attribytes[0];
24304 6925 }
24305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26893243 times.
26893243 else if(types[i]==cCAVEB)
24306 {
24307 types[i]=cCAVE;
24308 index=1;
24309 warpsfx2 = combobuf[cids[i]].attribytes[0];
24310 }
24311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26893243 times.
26893243 else if(types[i]==cCAVEC)
24312 {
24313 types[i]=cCAVE;
24314 index=2;
24315 warpsfx2 = combobuf[cids[i]].attribytes[0];
24316 }
24317
1/2
✓ Branch 0 taken 26893243 times.
✗ Branch 1 not taken.
26893243 else if(types[i]==cCAVED)
24318 {
24319 types[i]=cCAVE;
24320 index=3;
24321 warpsfx2 = combobuf[cids[i]].attribytes[0];
24322 }
24323
24324
2/2
✓ Branch 0 taken 9519 times.
✓ Branch 1 taken 26890649 times.
26900168 if(types[i]==cPIT)
24325 {
24326 9519 index=0;
24327 9519 warpsfx2 = combobuf[cids[i]].attribytes[0];
24328 9519 }
24329
2/2
✓ Branch 0 taken 5708 times.
✓ Branch 1 taken 26884941 times.
26890649 else if(types[i]==cPITB)
24330 {
24331 5708 types[i]=cPIT;
24332 5708 warpsfx2 = combobuf[cids[i]].attribytes[0];
24333 5708 index=1;
24334 5708 }
24335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26884941 times.
26884941 else if(types[i]==cPITC)
24336 {
24337 types[i]=cPIT;
24338 warpsfx2 = combobuf[cids[i]].attribytes[0];
24339 index=2;
24340 }
24341
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 26884935 times.
26884941 else if(types[i]==cPITD)
24342 {
24343 6 types[i]=cPIT;
24344 6 warpsfx2 = combobuf[cids[i]].attribytes[0];
24345 6 index=3;
24346 6 }
24347
1/2
✓ Branch 0 taken 26884935 times.
✗ Branch 1 not taken.
26884935 else if(types[i]==cPITR)
24348 {
24349 types[i]=cPIT;
24350 warpsfx2 = combobuf[cids[i]].attribytes[0];
24351 index=zc_oldrand()%4;
24352 }
24353
24354
2/2
✓ Branch 0 taken 32793 times.
✓ Branch 1 taken 26867375 times.
26900168 if(types[i]==cSTAIR)
24355 {
24356 32793 index=0;
24357 32793 warpsfx2 = combobuf[cids[i]].attribytes[0];
24358 32793 }
24359
2/2
✓ Branch 0 taken 1697 times.
✓ Branch 1 taken 26865678 times.
26867375 else if(types[i]==cSTAIRB)
24360 {
24361 1697 types[i]=cSTAIR;
24362 1697 warpsfx2 = combobuf[cids[i]].attribytes[0];
24363 1697 index=1;
24364 1697 }
24365
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 26865560 times.
26865678 else if(types[i]==cSTAIRC)
24366 {
24367 118 types[i]=cSTAIR;
24368 118 warpsfx2 = combobuf[cids[i]].attribytes[0];
24369 118 index=2;
24370 118 }
24371
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 26865357 times.
26865560 else if(types[i]==cSTAIRD)
24372 {
24373 203 types[i]=cSTAIR;
24374 203 warpsfx2 = combobuf[cids[i]].attribytes[0];
24375 203 index=3;
24376 203 }
24377
1/2
✓ Branch 0 taken 26865357 times.
✗ Branch 1 not taken.
26865357 else if(types[i]==cSTAIRR)
24378 {
24379 types[i]=cSTAIR;
24380 index=zc_oldrand()%4;
24381 warpsfx2 = combobuf[cids[i]].attribytes[0];
24382 }
24383
24384
2/2
✓ Branch 0 taken 6563 times.
✓ Branch 1 taken 26893605 times.
26900168 if(types[i]==cCAVE2)
24385 {
24386 6563 index=0;
24387 6563 warpsfx2 = combobuf[cids[i]].attribytes[0];
24388 6563 }
24389
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 26893272 times.
26893605 else if(types[i]==cCAVE2B)
24390 {
24391 333 types[i]=cCAVE2;
24392 333 index=1;
24393 333 warpsfx2 = combobuf[cids[i]].attribytes[0];
24394 333 }
24395
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 26893109 times.
26893272 else if(types[i]==cCAVE2C)
24396 {
24397 163 types[i]=cCAVE2;
24398 163 warpsfx2 = combobuf[cids[i]].attribytes[0];
24399 163 index=2;
24400 163 }
24401
1/2
✓ Branch 0 taken 26893109 times.
✗ Branch 1 not taken.
26893109 else if(types[i]==cCAVE2D)
24402 {
24403 types[i]=cCAVE2;
24404 warpsfx2 = combobuf[cids[i]].attribytes[0];
24405 index=3;
24406 }
24407
24408
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 26900013 times.
26900168 if(types[i]==cSWIMWARP)
24409 {
24410 155 index=0;
24411 155 warpsfx2 = combobuf[cids[i]].attribytes[0];
24412 155 }
24413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26900013 times.
26900013 else if(types[i]==cSWIMWARPB)
24414 {
24415 types[i]=cSWIMWARP;
24416 warpsfx2 = combobuf[cids[i]].attribytes[0];
24417 index=1;
24418 }
24419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26900013 times.
26900013 else if(types[i]==cSWIMWARPC)
24420 {
24421 types[i]=cSWIMWARP;
24422 warpsfx2 = combobuf[cids[i]].attribytes[0];
24423 index=2;
24424 }
24425
1/2
✓ Branch 0 taken 26900013 times.
✗ Branch 1 not taken.
26900013 else if(types[i]==cSWIMWARPD)
24426 {
24427 types[i]=cSWIMWARP;
24428 warpsfx2 = combobuf[cids[i]].attribytes[0];
24429 index=3;
24430 }
24431
24432
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 26899573 times.
26900168 if(types[i]==cDIVEWARP)
24433 {
24434 595 index=0;
24435 595 warpsfx2 = combobuf[cids[i]].attribytes[0];
24436 595 }
24437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26899573 times.
26899573 else if(types[i]==cDIVEWARPB)
24438 {
24439 types[i]=cDIVEWARP;
24440 warpsfx2 = combobuf[cids[i]].attribytes[0];
24441 index=1;
24442 }
24443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26899573 times.
26899573 else if(types[i]==cDIVEWARPC)
24444 {
24445 types[i]=cDIVEWARP;
24446 warpsfx2 = combobuf[cids[i]].attribytes[0];
24447 index=2;
24448 }
24449
1/2
✓ Branch 0 taken 26899573 times.
✗ Branch 1 not taken.
26899573 else if(types[i]==cDIVEWARPD)
24450 {
24451 types[i]=cDIVEWARP;
24452 warpsfx2 = combobuf[cids[i]].attribytes[0];
24453 index=3;
24454 }
24455
24456
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 26891896 times.
26900168 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
24457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26891896 times.
26891896 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
24458
2/2
✓ Branch 0 taken 26891752 times.
✓ Branch 1 taken 144 times.
26891896 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
24459 26900168 }
24460
24461 // Special case for step combos; otherwise, they act oddly in some cases
24462
8/8
✓ Branch 0 taken 6140068 times.
✓ Branch 1 taken 577601 times.
✓ Branch 2 taken 6076562 times.
✓ Branch 3 taken 63506 times.
✓ Branch 4 taken 1452 times.
✓ Branch 5 taken 639655 times.
✓ Branch 6 taken 128179 times.
✓ Branch 7 taken 126727 times.
6717669 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
24463 {
24464
7/8
✓ Branch 0 taken 5918586 times.
✓ Branch 1 taken 29797 times.
✓ Branch 2 taken 5918586 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1549 times.
✓ Branch 5 taken 5917037 times.
✓ Branch 6 taken 420 times.
✓ Branch 7 taken 1129 times.
6204741 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_qr(qr_MSGFREEZE)))
24465 5918166 type = types[1];
24466 5948383 }
24467
24468 //Generic Step
24469
7/8
✓ Branch 0 taken 6692593 times.
✓ Branch 1 taken 22172 times.
✓ Branch 2 taken 6692593 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1890 times.
✓ Branch 5 taken 6690703 times.
✓ Branch 6 taken 756 times.
✓ Branch 7 taken 1134 times.
6714765 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_qr(qr_MSGFREEZE)))
24470 {
24471 int32_t poses[4];
24472 int32_t sensPoses[4];
24473 6691837 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
24474 6691837 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
24475
4/6
✓ Branch 0 taken 2491107 times.
✓ Branch 1 taken 4200730 times.
✓ Branch 2 taken 2491107 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2491107 times.
6691837 if(diagonalMovement||NO_GRIDLOCK)
24476 4200730 getPoses(poses, tx+4, ty+4, tx+11, ty+11);
24477 2491107 else getPoses(poses, tx, ty, tx+15, ty+15);
24478 6691837 getPoses(sensPoses, tx, ty+(bigHitbox?0:8), tx+15, ty+15);
24479 6691837 bool hasStep[4] = {false};
24480
2/2
✓ Branch 0 taken 26767348 times.
✓ Branch 1 taken 6691837 times.
33459185 for(auto p = 0; p < 4; ++p)
24481 {
24482
2/2
✓ Branch 0 taken 26752704 times.
✓ Branch 1 taken 187283572 times.
214036276 for(auto lyr = 0; lyr < 7; ++lyr)
24483 {
24484
2/2
✓ Branch 0 taken 87632461 times.
✓ Branch 1 taken 99651111 times.
187283572 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
24485
4/4
✓ Branch 0 taken 87632461 times.
✓ Branch 1 taken 99651111 times.
✓ Branch 2 taken 14644 times.
✓ Branch 3 taken 187268928 times.
187283572 if((cmb && (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS)))
24486 187283572 || types[p] == cSTEP)
24487 {
24488 14644 hasStep[p] = true;
24489 14644 break;
24490 }
24491 187268928 }
24492 26767348 }
24493 6691837 bool canNormalStep = true;
24494
2/2
✓ Branch 0 taken 2348 times.
✓ Branch 1 taken 6704410 times.
6706758 for(auto p = 0; p < 4; ++p)
24495 {
24496
2/2
✓ Branch 0 taken 6698338 times.
✓ Branch 1 taken 6072 times.
6704410 if(poses[p] < 0) continue;
24497
2/2
✓ Branch 0 taken 8849 times.
✓ Branch 1 taken 6689489 times.
6698338 if(!hasStep[p])
24498 {
24499 6689489 canNormalStep = false;
24500 6689489 break;
24501 }
24502 8849 }
24503
2/2
✓ Branch 0 taken 26767348 times.
✓ Branch 1 taken 6691837 times.
33459185 for(auto p = 0; p < 4; ++p)
24504 {
24505
2/2
✓ Branch 0 taken 187371436 times.
✓ Branch 1 taken 26767348 times.
214138784 for(auto lyr = 0; lyr < 7; ++lyr)
24506 {
24507
2/2
✓ Branch 0 taken 99665643 times.
✓ Branch 1 taken 87705793 times.
187371436 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
24508
2/2
✓ Branch 0 taken 98058065 times.
✓ Branch 1 taken 89313371 times.
187371436 newcombo const* cmb2 = sensPoses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[sensPoses[p]]];
24509
6/6
✓ Branch 0 taken 65744 times.
✓ Branch 1 taken 187305692 times.
✓ Branch 2 taken 27405 times.
✓ Branch 3 taken 38339 times.
✓ Branch 4 taken 27287 times.
✓ Branch 5 taken 118 times.
187371436 if(canNormalStep && cmb && (cmb->triggerflags[0] & combotriggerSTEP))
24510 {
24511 118 do_trigger_combo(lyr,poses[p]);
24512
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 59 times.
118 if(poses[p] == sensPoses[p]) continue;
24513 59 }
24514
4/4
✓ Branch 0 taken 89313312 times.
✓ Branch 1 taken 98058065 times.
✓ Branch 2 taken 89306802 times.
✓ Branch 3 taken 6510 times.
187371377 if(cmb2 && (cmb2->triggerflags[0] & combotriggerSTEPSENS))
24515 {
24516 6510 do_trigger_combo(lyr,sensPoses[p]);
24517 6510 }
24518 187371377 }
24519 26767348 }
24520 6691837 word c = tmpscr->numFFC();
24521
2/2
✓ Branch 0 taken 186478256 times.
✓ Branch 1 taken 6691837 times.
193170093 for(word i=0; i<c; i++)
24522 {
24523 186478256 bool found = false;
24524
2/2
✓ Branch 0 taken 372956512 times.
✓ Branch 1 taken 186478256 times.
559434768 for(auto xch = 0; xch < 2; ++xch)
24525 {
24526
2/2
✓ Branch 0 taken 745913024 times.
✓ Branch 1 taken 372956512 times.
1118869536 for(auto ych = 0; ych < 2; ++ych)
24527 {
24528
2/2
✓ Branch 0 taken 745309930 times.
✓ Branch 1 taken 603094 times.
745913024 if (ffcIsAt(i, xPoses[xch], yPoses[ych]))
24529 {
24530 603094 found = true;
24531 603094 }
24532 745913024 }
24533 372956512 }
24534
2/2
✓ Branch 0 taken 186256651 times.
✓ Branch 1 taken 221605 times.
186478256 if (found)
24535 {
24536 221605 ffcdata& ffc = tmpscr->ffcs[i];
24537 221605 newcombo const* cmb = &combobuf[ffc.data];
24538
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 221603 times.
221605 if (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS))
24539 {
24540 2 do_trigger_combo_ffc(i);
24541 2 }
24542 221605 }
24543 186478256 }
24544 6691837 }
24545
2/2
✓ Branch 0 taken 6712385 times.
✓ Branch 1 taken 2380 times.
6714765 if(isDiving()) //Dive-> triggerflag
24546 {
24547 2380 int pos = COMBOPOS(x+8,y+8);
24548 2380 int x1=x,x2=x+15,y1=y+(bigHitbox?0:8),y2=y+15;
24549 2380 int xposes[] = {x1,x1,x2,x2};
24550 2380 int yposes[] = {y1,y2,y1,y2};
24551 int32_t poses[4];
24552 2380 getPoses(poses,x1,y1,x2,y2);
24553
2/2
✓ Branch 0 taken 16660 times.
✓ Branch 1 taken 2380 times.
19040 for(auto lyr = 0; lyr < 7; ++lyr)
24554 {
24555 16660 mapscr* s = FFCore.tempScreens[lyr];
24556 16660 newcombo const& cmb = combobuf[s->data[pos]];
24557 16660 bool didtrig = false;
24558
1/2
✓ Branch 0 taken 16660 times.
✗ Branch 1 not taken.
16660 if (cmb.triggerflags[3] & combotriggerDIVETRIG)
24559 {
24560 do_trigger_combo(lyr,pos);
24561 didtrig = true;
24562 }
24563
2/2
✓ Branch 0 taken 66640 times.
✓ Branch 1 taken 16660 times.
83300 for(auto q = 0; q < 4; ++q)
24564 {
24565
2/2
✓ Branch 0 taken 33593 times.
✓ Branch 1 taken 33047 times.
66640 if(poses[q] < 0) continue;
24566
3/4
✓ Branch 0 taken 16660 times.
✓ Branch 1 taken 16933 times.
✓ Branch 2 taken 16660 times.
✗ Branch 3 not taken.
33593 if(poses[q] == pos && didtrig) continue;
24567 33593 newcombo const& cmb = combobuf[s->data[poses[q]]];
24568
1/2
✓ Branch 0 taken 33593 times.
✗ Branch 1 not taken.
33593 if (cmb.triggerflags[3] & combotriggerDIVESENSTRIG)
24569 do_trigger_combo(lyr,poses[q]);
24570 33593 }
24571 16660 }
24572 2380 word c = tmpscr->numFFC();
24573
2/2
✓ Branch 0 taken 66544 times.
✓ Branch 1 taken 2380 times.
68924 for(word i=0; i<c; i++)
24574 {
24575 66544 ffcdata& ffc = tmpscr->ffcs[i];
24576 66544 newcombo const& cmb = combobuf[ffc.data];
24577
2/4
✓ Branch 0 taken 66544 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66544 times.
66544 if ((cmb.triggerflags[3] & combotriggerDIVETRIG) && ffcIsAt(i, x+8, y+8))
24578 {
24579 do_trigger_combo_ffc(i);
24580 }
24581
1/2
✓ Branch 0 taken 66544 times.
✗ Branch 1 not taken.
66544 else if(cmb.triggerflags[3] & combotriggerDIVESENSTRIG)
24582 {
24583 for(auto q = 0; q < 4; ++q)
24584 {
24585 if(ffcIsAt(i, xposes[q], yposes[q]))
24586 {
24587 do_trigger_combo_ffc(i);
24588 break;
24589 }
24590 }
24591 }
24592 66544 }
24593 2380 }
24594
24595 //
24596 // Now, let's check for Save combos...
24597 //
24598 6714765 x1 = tx+4;
24599 6714765 x2 = tx+11;
24600 6714765 y1 = ty+4;
24601 6714765 y2 = ty+11;
24602
24603 6714765 types[0] = COMBOTYPE(x1,y1);
24604 6714765 cids[0] = MAPCOMBO(x1,y1);
24605
24606
2/2
✓ Branch 0 taken 6543144 times.
✓ Branch 1 taken 171621 times.
6714765 if(MAPFFCOMBO(x1,y1))
24607 {
24608 171621 types[0] = FFCOMBOTYPE(x1,y1);
24609 171621 cids[0] = MAPFFCOMBO(x1,y1);
24610 171621 }
24611
24612 6714765 types[1] = COMBOTYPE(x1,y2);
24613 6714765 cids[1] = MAPCOMBO(x1,y2);
24614
24615
2/2
✓ Branch 0 taken 6587700 times.
✓ Branch 1 taken 127065 times.
6714765 if(MAPFFCOMBO(x1,y2))
24616 {
24617 127065 types[1] = FFCOMBOTYPE(x1,y2);
24618 127065 cids[1] = MAPFFCOMBO(x1,y2);
24619 127065 }
24620
24621 6714765 types[2] = COMBOTYPE(x2,y1);
24622 6714765 cids[2] = MAPCOMBO(x2,y1);
24623
24624
2/2
✓ Branch 0 taken 6543854 times.
✓ Branch 1 taken 170911 times.
6714765 if(MAPFFCOMBO(x2,y1))
24625 {
24626 170911 types[2] = FFCOMBOTYPE(x2,y1);
24627 170911 cids[2] = MAPFFCOMBO(x2,y1);
24628 170911 }
24629
24630 6714765 types[3] = COMBOTYPE(x2,y2);
24631 6714765 cids[3] = MAPCOMBO(x2,y2);
24632
24633
2/2
✓ Branch 0 taken 6587231 times.
✓ Branch 1 taken 127534 times.
6714765 if(MAPFFCOMBO(x2,y2))
24634 {
24635 127534 types[3] = FFCOMBOTYPE(x2,y2);
24636 127534 cids[3] = MAPFFCOMBO(x2,y2);
24637 127534 }
24638
24639
24640
2/2
✓ Branch 0 taken 6714765 times.
✓ Branch 1 taken 26900492 times.
33615257 for(int32_t i=0; i<4; i++)
24641 {
24642
2/2
✓ Branch 0 taken 26900168 times.
✓ Branch 1 taken 324 times.
26900492 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
24643 {
24644
2/4
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 324 times.
✗ Branch 3 not taken.
324 if(types[i] == cSAVE || types[i] == cSAVE2)
24645 {
24646 types[i] = cNONE;
24647 setsave = false;
24648 break;
24649 }
24650 324 }
24651
2/2
✓ Branch 0 taken 26899206 times.
✓ Branch 1 taken 1286 times.
26900492 if(types[i]==cSAVE) setsave=true;
24652
24653
1/2
✓ Branch 0 taken 26900492 times.
✗ Branch 1 not taken.
26900492 if(types[i]==cSAVE2) setsave=true;
24654 26900492 }
24655
24656
8/8
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 6714334 times.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 335 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 106 times.
✓ Branch 7 taken 229 times.
6714765 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24657 {
24658 229 last_savepoint_id = cids[0];
24659 229 type = types[0];
24660 229 }
24661 //
24662 // Now, let's check for Drowning combos...
24663 //
24664
4/4
✓ Branch 0 taken 2617082 times.
✓ Branch 1 taken 4097683 times.
✓ Branch 2 taken 10358 times.
✓ Branch 3 taken 2626100 times.
6714765 if(get_qr(qr_DROWN) || CanSideSwim())
24665 {
24666 4108041 y1 = ty+9;
24667 4108041 y2 = ty+15;
24668
2/2
✓ Branch 0 taken 1043091 times.
✓ Branch 1 taken 3064950 times.
4108041 if (get_qr(qr_SMARTER_WATER))
24669 {
24670
4/4
✓ Branch 0 taken 11287 times.
✓ Branch 1 taken 1031804 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 8892 times.
1052005 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
24671
2/2
✓ Branch 0 taken 10186 times.
✓ Branch 1 taken 1101 times.
11287 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
24672
2/2
✓ Branch 0 taken 8914 times.
✓ Branch 1 taken 1272 times.
10186 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
24673 8914 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
24674 1043091 }
24675 else
24676 {
24677 3064950 types[0] = COMBOTYPE(x1,y1);
24678
24679
2/2
✓ Branch 0 taken 2961467 times.
✓ Branch 1 taken 103483 times.
3064950 if(MAPFFCOMBO(x1,y1))
24680 103483 types[0] = FFCOMBOTYPE(x1,y1);
24681
24682 3064950 types[1] = COMBOTYPE(x1,y2);
24683
24684
2/2
✓ Branch 0 taken 2974935 times.
✓ Branch 1 taken 90015 times.
3064950 if(MAPFFCOMBO(x1,y2))
24685 90015 types[1] = FFCOMBOTYPE(x1,y2);
24686
24687 3064950 types[2] = COMBOTYPE(x2,y1);
24688
24689
2/2
✓ Branch 0 taken 2959782 times.
✓ Branch 1 taken 105168 times.
3064950 if(MAPFFCOMBO(x2,y1))
24690 105168 types[2] = FFCOMBOTYPE(x2,y1);
24691
24692 3064950 types[3] = COMBOTYPE(x2,y2);
24693
24694
2/2
✓ Branch 0 taken 2971505 times.
✓ Branch 1 taken 93445 times.
3064950 if(MAPFFCOMBO(x2,y2))
24695 93445 types[3] = FFCOMBOTYPE(x2,y2);
24696
24697 3064950 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
24698
2/2
✓ Branch 0 taken 2966196 times.
✓ Branch 1 taken 98754 times.
3064950 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
24699 98754 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
24700
24701
5/6
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 3055984 times.
✓ Branch 2 taken 8624 times.
✓ Branch 3 taken 342 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8166 times.
3073116 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
24702
3/4
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 458 times.
✓ Branch 2 taken 8166 times.
✗ Branch 3 not taken.
8624 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
24703 8166 water = typec;
24704 }
24705 4108041 }
24706
24707
24708 // Pits have a bigger 'hitbox' than stairs...
24709 6734141 x1 = tx+7;
24710 6734141 x2 = tx+8;
24711 6734141 y1 = ty+7+(bigHitbox?0:4);
24712 6734141 y2 = ty+8+(bigHitbox?0:4);
24713
24714 6734141 types[0] = COMBOTYPE(x1,y1);
24715 6734141 cids[0] = MAPCOMBO(x1,y1);
24716
24717
2/2
✓ Branch 0 taken 6606039 times.
✓ Branch 1 taken 128102 times.
6734141 if(MAPFFCOMBO(x1,y1))
24718 {
24719 128102 types[0] = FFCOMBOTYPE(x1,y1);
24720 128102 cids[0] = MAPFFCOMBO(x1,y1);
24721 128102 }
24722
24723 6734141 types[1] = COMBOTYPE(x1,y2);
24724 6734141 cids[1] = MAPCOMBO(x1,y2);
24725
24726
2/2
✓ Branch 0 taken 6607089 times.
✓ Branch 1 taken 127052 times.
6734141 if(MAPFFCOMBO(x1,y2))
24727 {
24728 127052 types[1] = FFCOMBOTYPE(x1,y2);
24729 127052 cids[1] = MAPFFCOMBO(x1,y2);
24730 127052 }
24731 6734141 types[2] = COMBOTYPE(x2,y1);
24732 6734141 cids[2] = MAPCOMBO(x2,y1);
24733
24734
2/2
✓ Branch 0 taken 6605375 times.
✓ Branch 1 taken 128766 times.
6734141 if(MAPFFCOMBO(x2,y1))
24735 {
24736 128766 types[2] = FFCOMBOTYPE(x2,y1);
24737 128766 cids[2] = MAPFFCOMBO(x2,y1);
24738 128766 }
24739
24740 6734141 types[3] = COMBOTYPE(x2,y2);
24741 6734141 cids[3] = MAPCOMBO(x2,y2);
24742
24743
2/2
✓ Branch 0 taken 6606395 times.
✓ Branch 1 taken 127746 times.
6734141 if(MAPFFCOMBO(x2,y2))
24744 {
24745 127746 types[3] = FFCOMBOTYPE(x2,y2);
24746 127746 cids[3] = MAPFFCOMBO(x2,y2);
24747 127746 }
24748
24749
2/2
✓ Branch 0 taken 26900492 times.
✓ Branch 1 taken 6734141 times.
33634633 for(int32_t i=0; i<4; i++)
24750 {
24751
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 26900228 times.
26900492 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
24752 {
24753 264 types[i] = cNONE;
24754 264 continue;
24755 }
24756
2/2
✓ Branch 0 taken 3037 times.
✓ Branch 1 taken 26897191 times.
26900228 if(types[i]==cPIT)
24757 {
24758 3037 index=0;
24759 3037 warpsfx2 = combobuf[cids[i]].attribytes[0];
24760 3037 }
24761
2/2
✓ Branch 0 taken 5004 times.
✓ Branch 1 taken 26892187 times.
26897191 else if(types[i]==cPITB)
24762 {
24763 5004 types[i]=cPIT;
24764 5004 index=1;
24765 5004 warpsfx2 = combobuf[cids[i]].attribytes[0];
24766 5004 }
24767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26892187 times.
26892187 else if(types[i]==cPITC)
24768 {
24769 types[i]=cPIT;
24770 index=2;
24771 warpsfx2 = combobuf[cids[i]].attribytes[0];
24772 }
24773
2/2
✓ Branch 0 taken 26892185 times.
✓ Branch 1 taken 2 times.
26892187 else if(types[i]==cPITD)
24774 {
24775 2 types[i]=cPIT;
24776 2 index=3;
24777 2 warpsfx2 = combobuf[cids[i]].attribytes[0];
24778 2 }
24779 26900228 }
24780
24781
8/8
✓ Branch 0 taken 6723118 times.
✓ Branch 1 taken 11023 times.
✓ Branch 2 taken 6723100 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 6722902 times.
✓ Branch 5 taken 198 times.
✓ Branch 6 taken 10774 times.
✓ Branch 7 taken 6731832 times.
6734141 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
24782
3/8
✓ Branch 0 taken 2221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2221 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2221 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
24234 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_qr(qr_MSGFREEZE)))
24783 2221 type=cPIT;
24784
24785 //
24786 // Time to act on our results for type, flag, flag2 and flag3...
24787 //
24788
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 6733824 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229 times.
6734053 if(type==cSAVE&&currscr<128)
24789 229 *ls=1;
24790
24791
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6734053 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6734053 if(type==cSAVE2&&currscr<128)
24792 *ls=2;
24793
24794
8/8
✓ Branch 0 taken 6714773 times.
✓ Branch 1 taken 19280 times.
✓ Branch 2 taken 6698358 times.
✓ Branch 3 taken 16415 times.
✓ Branch 4 taken 6697828 times.
✓ Branch 5 taken 530 times.
✓ Branch 6 taken 13798 times.
✓ Branch 7 taken 6711626 times.
6734053 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
24795 {
24796 50023 fairycircle(REFILL_LIFE);
24797
24798
2/2
✓ Branch 0 taken 4332 times.
✓ Branch 1 taken 22963 times.
50023 if(fairyclk!=0) return;
24799 4332 }
24800
24801
7/8
✓ Branch 0 taken 6702146 times.
✓ Branch 1 taken 13812 times.
✓ Branch 2 taken 6702064 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 6702064 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13826 times.
✓ Branch 7 taken 6715890 times.
6715958 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
24802 {
24803 27720 fairycircle(REFILL_MAGIC);
24804
24805
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 1 times.
27720 if(fairyclk!=0) return;
24806 1 }
24807
24808
7/8
✓ Branch 0 taken 6702031 times.
✓ Branch 1 taken 13860 times.
✓ Branch 2 taken 6701850 times.
✓ Branch 3 taken 181 times.
✓ Branch 4 taken 6701850 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13894 times.
✓ Branch 7 taken 6715744 times.
6715891 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
24809 {
24810 27935 fairycircle(REFILL_ALL);
24811
24812
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 19 times.
27935 if(fairyclk!=0) return;
24813 19 }
24814
24815 // Just in case Hero was moved off of the fairy flag
24816
1/2
✓ Branch 0 taken 6715763 times.
✗ Branch 1 not taken.
6715763 if(refilling==REFILL_FAIRYDONE)
24817 {
24818 fairycircle(REFILL_NONE);
24819
24820 if(fairyclk!=0) return;
24821 }
24822
24823
6/8
✓ Branch 0 taken 6701858 times.
✓ Branch 1 taken 13905 times.
✓ Branch 2 taken 6701858 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6701858 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13916 times.
✓ Branch 7 taken 6715642 times.
6715763 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
24824 {
24825 27821 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
24826 27821 win_game();
24827 27821 return;
24828 }
24829
24830
4/4
✓ Branch 0 taken 6683369 times.
✓ Branch 1 taken 32273 times.
✓ Branch 2 taken 6697433 times.
✓ Branch 3 taken 18209 times.
6715642 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS))
24831 18209 return;
24832
24833
4/4
✓ Branch 0 taken 6681018 times.
✓ Branch 1 taken 16415 times.
✓ Branch 2 taken 721 times.
✓ Branch 3 taken 6680297 times.
6697433 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
24834 {
24835
24836
4/4
✓ Branch 0 taken 2089 times.
✓ Branch 1 taken 15047 times.
✓ Branch 2 taken 15415 times.
✓ Branch 3 taken 16616 times.
17136 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepsecret || get_qr(qr_TRIGGERSREPEAT))
24837 {
24838 30462 stepsecret = (((ty+8)&0xF0)+((tx+8)>>4));
24839 30462 sfx(combobuf[tmpscr->data[stepsecret]].attribytes[0],pan((int32_t)x));
24840 //zprint("Step Secrets Sound: %d\n", combobuf[tmpscr->data[stepsecret]].attribytes[0]);
24841
24842
4/4
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 2631 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 198 times.
30462 if(type==cTRIGFLAG && canPermSecret())
24843 {
24844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
24845
24846 198 hidden_entrance(0,true,false);
24847 198 }
24848 else
24849 {
24850 2658 bool only16_31 = get_qr(qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
24851 2658 hidden_entrance(0,true,only16_31);
24852 }
24853 2856 }
24854 19472 }
24855
2/2
✓ Branch 0 taken 1415 times.
✓ Branch 1 taken 6678882 times.
6680297 else if(!didstrig)
24856 {
24857 6678882 stepsecret = -1;
24858 6678882 }
24859
24860 //Better? Dock collision
24861
24862 // Drown if:
24863 // * Water (obviously walkable),
24864 // * Quest Rule allows it,
24865 // * Not on stepladder,
24866 // * Not jumping,
24867 // * Not hovering,
24868 // * Not rafting,
24869 // * Not swallowed,
24870 // * Not a dried lake.
24871
24872 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
24873
9/12
✓ Branch 0 taken 16842 times.
✓ Branch 1 taken 6645421 times.
✓ Branch 2 taken 16259 times.
✓ Branch 3 taken 583 times.
✓ Branch 4 taken 16259 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10693 times.
✓ Branch 7 taken 5566 times.
✓ Branch 8 taken 10693 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 10693 times.
6709938 if(water > 0 && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE
24874
4/8
✓ Branch 0 taken 10693 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10693 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10693 times.
✗ Branch 7 not taken.
10693 && ((get_qr(qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim())
24875
4/4
✓ Branch 0 taken 10693 times.
✓ Branch 1 taken 10693 times.
✓ Branch 2 taken 10693 times.
✓ Branch 3 taken 10693 times.
10693 && (sideview_mode() || !platform_ffc))
24876 {
24877
7/8
✓ Branch 0 taken 10504 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 10501 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2518 times.
✓ Branch 5 taken 7983 times.
✓ Branch 6 taken 2518 times.
✗ Branch 7 not taken.
10693 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
24878 {
24879
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!(ladderx+laddery)) drownCombo = water;
24880
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 188 times.
192 if (combobuf[water].usrflags&cflag1) Drown(1);
24881 188 else Drown();
24882
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 16 times.
192 if(byte drown_sfx = combobuf[water].attribytes[4])
24883 16 sfx(drown_sfx, pan(int32_t(x)));
24884 192 }
24885
2/2
✓ Branch 0 taken 10237 times.
✓ Branch 1 taken 264 times.
10501 else if (!isSwimming())
24886 {
24887 264 SetSwim();
24888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if (!IsSideSwim()) attackclk = charging = spins = 0;
24889 264 landswim=0;
24890 264 return;
24891 }
24892 10429 }
24893
24894
24895
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 6683051 times.
6683385 if(type==cSTEP)
24896 {
24897 //zprint2("Hero.HasHeavyBoots(): is: %s\n", ( (Hero.HasHeavyBoots()) ? "true" : "false" ));
24898
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 186 times.
334 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepnext)
24899 {
24900 186 stepnext=((ty+8)&0xF0)+((tx+8)>>4);
24901
24902 if
24903 (
24904
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 19 times.
186 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
24905
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167 (!combobuf[tmpscr->data[stepnext]].attribytes[1] || (combobuf[tmpscr->data[stepnext]].attribytes[1] && game->item[combobuf[tmpscr->data[stepnext]].attribytes[1]]) )
24906 && /*HEAVY*/
24907
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
24908 )
24909
24910 {
24911 167 sfx(combobuf[tmpscr->data[stepnext]].attribytes[0],pan((int32_t)x));
24912 167 tmpscr->data[stepnext]++;
24913
24914 167 }
24915
24916 if
24917 (
24918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186 times.
186 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
24919 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
24920 && /*HEAVY*/
24921 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
24922 )
24923 {
24924 int32_t stepc = tmpscr->data[stepnext];
24925 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
24926 for(int32_t k=0; k<176; k++)
24927 {
24928 if(tmpscr->data[k]==stepc)
24929 {
24930 tmpscr->data[k]++;
24931 }
24932 }
24933 }
24934
24935 if
24936 (
24937
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 179 times.
186 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
24938
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
24939 && /*HEAVY*/
24940
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
24941 )
24942 {
24943 7 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
24944
2/2
✓ Branch 0 taken 1232 times.
✓ Branch 1 taken 7 times.
1239 for(int32_t k=0; k<176; k++)
24945 {
24946 if(
24947
3/4
✓ Branch 0 taken 1232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 1051 times.
2382 (combobuf[tmpscr->data[k]].type==cSTEP)||
24948
1/2
✓ Branch 0 taken 1232 times.
✗ Branch 1 not taken.
1232 (combobuf[tmpscr->data[k]].type==cSTEPSAME)||
24949
2/2
✓ Branch 0 taken 1150 times.
✓ Branch 1 taken 82 times.
1232 (combobuf[tmpscr->data[k]].type==cSTEPALL)||
24950 1150 (combobuf[tmpscr->data[k]].type==cSTEPCOPY)
24951 )
24952 {
24953 181 tmpscr->data[k]++;
24954 181 }
24955 1232 }
24956 7 }
24957 186 }
24958 334 }
24959
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6683051 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6683051 else if(type==cSTEPSFX && action == walking)
24960 {
24961 trigger_stepfx(0, COMBOPOS(tx+8,ty+8), true);
24962 }
24963 6683051 else stepnext = -1;
24964
24965 6683385 detail_int[0]=tx;
24966 6683385 detail_int[1]=ty;
24967
24968
24969
8/8
✓ Branch 0 taken 6682929 times.
✓ Branch 1 taken 456 times.
✓ Branch 2 taken 877 times.
✓ Branch 3 taken 6682508 times.
✓ Branch 4 taken 6680520 times.
✓ Branch 5 taken 1988 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
6683410 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
24970
5/6
✓ Branch 0 taken 6679568 times.
✓ Branch 1 taken 952 times.
✓ Branch 2 taken 6679547 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 6679547 times.
✗ Branch 5 not taken.
6680520 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
24971
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 6679522 times.
6679547 !(type==cDIVEWARP && isDiving()))
24972 6679533 {
24973 RaftingStuff:
24974
2/2
✓ Branch 0 taken 6678974 times.
✓ Branch 1 taken 559 times.
6679533 if (get_qr(qr_BETTER_RAFT_2))
24975 {
24976 559 bool doraft = true;
24977
4/6
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
559 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
24978 {
24979
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
24980 {
24981 3 doraft = false;
24982 3 }
24983 3 }
24984 //if (mfRAFT)
24985 int32_t rafttypes[2];
24986 559 int32_t raftx1 = tx+6;
24987 559 int32_t raftx2 = tx+9;
24988 559 int32_t rafty = ty+11;
24989 int32_t raftflags[3];
24990 559 rafttypes[0]=rafttypes[1]=-1;
24991 559 raftflags[0]=raftflags[1]=raftflags[2]=0;
24992 559 rafttypes[0] = MAPFLAG(raftx1,rafty);
24993 559 rafttypes[1] = MAPFLAG(raftx2,rafty);
24994
24995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
24996 559 raftflags[0] = rafttypes[0];
24997
24998
24999 559 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
25000 559 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
25001
25002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
25003 559 raftflags[1] = rafttypes[0];
25004
25005 559 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
25006 559 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
25007
25008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
25009 559 raftflags[2] = rafttypes[0];
25010
25011
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 559 times.
2236 for (int32_t m = 0; m < 3; ++m)
25012 {
25013
2/4
✓ Branch 0 taken 1677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1677 times.
1677 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
25014 {
25015 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
25016 {
25017 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
25018 {
25019 reset_swordcharge();
25020 action=rafting; FFCore.setHeroAction(rafting);
25021 raftclk=0;
25022 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25023 else sfx(tmpscr->secretsfx);
25024 }
25025 else if (get_qr(qr_BETTER_RAFT) && doraft)
25026 {
25027 for (int32_t i = 0; i < 4; ++i)
25028 {
25029 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
25030 {
25031 reset_swordcharge();
25032 action=rafting; FFCore.setHeroAction(rafting);
25033 raftclk=0;
25034 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25035 else sfx(tmpscr->secretsfx);
25036 dir = i;
25037 break;
25038 }
25039 }
25040 }
25041 }
25042 }
25043 1677 }
25044 559 }
25045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6679533 times.
6679533 if (RaftPass) return;
25046
3/3
✓ Branch 0 taken 34031 times.
✓ Branch 1 taken 6644442 times.
✓ Branch 2 taken 1060 times.
6679533 switch(flag)
25047 {
25048 case mfDIVE_ITEM:
25049
6/8
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1036 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
1060 if(isDiving() && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
25050 {
25051 30 additem(x, y, tmpscr->catchall,
25052 15 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
25053 15 sfx(tmpscr->secretsfx);
25054 15 }
25055
25056 1060 return;
25057
25058 case mfRAFT:
25059 case mfRAFT_BRANCH:
25060
25061 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
25062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34031 times.
34031 if (!get_qr(qr_BETTER_RAFT_2))
25063 {
25064 34031 bool doraft = true;
25065
5/6
✓ Branch 0 taken 34031 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2122 times.
✓ Branch 3 taken 31909 times.
✓ Branch 4 taken 576 times.
✓ Branch 5 taken 1546 times.
34031 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
25066 {
25067
5/6
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✓ Branch 3 taken 738 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 785 times.
1546 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25068 {
25069 785 doraft = false;
25070 785 }
25071 1546 }
25072
13/16
✓ Branch 0 taken 31056 times.
✓ Branch 1 taken 2975 times.
✓ Branch 2 taken 3282 times.
✓ Branch 3 taken 27774 times.
✓ Branch 4 taken 3262 times.
✓ Branch 5 taken 20 times.
✓ Branch 6 taken 3251 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 3251 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3251 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3251 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1531 times.
✓ Branch 15 taken 1720 times.
34031 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
25073 {
25074
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
1720 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
25075 {
25076 355 reset_swordcharge();
25077 355 action=rafting; FFCore.setHeroAction(rafting);
25078 355 raftclk=0;
25079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 355 times.
355 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25080 355 else sfx(tmpscr->secretsfx);
25081 355 }
25082
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1365 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1365 else if (get_qr(qr_BETTER_RAFT) && doraft)
25083 {
25084 for (int32_t i = 0; i < 4; ++i)
25085 {
25086 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
25087 {
25088 reset_swordcharge();
25089 action=rafting; FFCore.setHeroAction(rafting);
25090 raftclk=0;
25091 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25092 else sfx(tmpscr->secretsfx);
25093 dir = i;
25094 break;
25095 }
25096 }
25097 }
25098 1720 }
25099 34031 }
25100
25101 34031 return;
25102
25103 default:
25104 6644442 break;
25105 //return;
25106 }
25107
25108
2/3
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 6644168 times.
✗ Branch 2 not taken.
6644442 switch(flag2)
25109 {
25110 case mfDIVE_ITEM:
25111 if(isDiving() && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
25112 {
25113 additem(x, y, tmpscr->catchall,
25114 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
25115 sfx(tmpscr->secretsfx);
25116 }
25117
25118 return;
25119
25120 case mfRAFT:
25121 case mfRAFT_BRANCH:
25122
25123 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
25124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if (!get_qr(qr_BETTER_RAFT_2))
25125 {
25126 274 bool doraft = true;
25127
2/6
✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 274 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
274 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
25128 {
25129 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25130 {
25131 doraft = false;
25132 }
25133 }
25134
10/16
✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 139 times.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 135 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 135 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 121 times.
✓ Branch 15 taken 14 times.
274 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
25135 {
25136
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 9 times.
14 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
25137 {
25138 5 reset_swordcharge();
25139 5 action=rafting; FFCore.setHeroAction(rafting);
25140 5 raftclk=0;
25141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25142 5 else sfx(tmpscr->secretsfx);
25143 5 }
25144
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 else if (get_qr(qr_BETTER_RAFT) && doraft)
25145 {
25146 for (int32_t i = 0; i < 4; ++i)
25147 {
25148 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
25149 {
25150 reset_swordcharge();
25151 action=rafting; FFCore.setHeroAction(rafting);
25152 raftclk=0;
25153 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25154 else sfx(tmpscr->secretsfx);
25155 dir = i;
25156 break;
25157 }
25158 }
25159 }
25160 14 }
25161 274 }
25162
25163 274 return;
25164
25165 default:
25166 6644168 break;
25167 //return;
25168 }
25169
25170
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6644168 times.
✗ Branch 2 not taken.
6644168 switch(flag3)
25171 {
25172 case mfDIVE_ITEM:
25173 if(isDiving() && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
25174 {
25175 additem(x, y, tmpscr->catchall,
25176 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
25177 sfx(tmpscr->secretsfx);
25178 }
25179
25180 return;
25181
25182 case mfRAFT:
25183 case mfRAFT_BRANCH:
25184
25185 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
25186 if (!get_qr(qr_BETTER_RAFT_2))
25187 {
25188 bool doraft = true;
25189 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
25190 {
25191 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25192 {
25193 doraft = false;
25194 }
25195 }
25196 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
25197 {
25198 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
25199 {
25200 reset_swordcharge();
25201 action=rafting; FFCore.setHeroAction(rafting);
25202 raftclk=0;
25203 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25204 else sfx(tmpscr->secretsfx);
25205 }
25206 else if (get_qr(qr_BETTER_RAFT) && doraft)
25207 {
25208 for (int32_t i = 0; i < 4; ++i)
25209 {
25210 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
25211 {
25212 reset_swordcharge();
25213 action=rafting; FFCore.setHeroAction(rafting);
25214 raftclk=0;
25215 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25216 else sfx(tmpscr->secretsfx);
25217 dir = i;
25218 break;
25219 }
25220 }
25221 }
25222 }
25223 }
25224
25225 return;
25226
25227 default:
25228 6644168 return;
25229 }
25230 }
25231
25232
25233 3852 int32_t t=(currscr<128)?0:1;
25234
25235
3/4
✓ Branch 0 taken 3396 times.
✓ Branch 1 taken 456 times.
✓ Branch 2 taken 3852 times.
✗ Branch 3 not taken.
3852 if((type==cCAVE || type==cCAVE2) && (tmpscr[t].tilewarptype[index]==wtNOWARP)) return;
25236
25237 //don't do this for canceled warps -DD
25238 //I have no idea why we do this skip, but I'll dutifully propagate it to all cases below...
25239 /*if(tmpscr[t].tilewarptype[index] != wtNOWARP)
25240 {
25241 draw_screen(tmpscr);
25242 advanceframe(true);
25243 }*/
25244
25245 3852 bool skippedaframe=false;
25246
25247
6/6
✓ Branch 0 taken 3396 times.
✓ Branch 1 taken 456 times.
✓ Branch 2 taken 2975 times.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 1988 times.
✓ Branch 5 taken 987 times.
3852 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
25248 {
25249 // Stop music only if:
25250 // * entering a Guy Cave
25251 // * warping to a DMap whose music is different.
25252
25253 2865 int32_t tdm = tmpscr[t].tilewarpdmap[index];
25254
25255
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 1910 times.
2865 if(tmpscr[t].tilewarptype[index]<=wtPASS)
25256 {
25257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 955 times.
955 if (FFCore.can_dmap_change_music(tdm))
25258 {
25259
3/4
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 486 times.
955 if ((DMaps[currdmap].flags & dmfCAVES) && tmpscr[t].tilewarptype[index] == wtCAVE)
25260 486 music_stop();
25261 955 }
25262 955 }
25263 else
25264 {
25265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1910 times.
1910 if (FFCore.can_dmap_change_music(tdm))
25266 {
25267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1910 times.
1910 if (zcmusic != NULL)
25268 {
25269 if (strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
25270 (zcmusic->type == ZCMF_GME && zcmusic->track != DMaps[tdm].tmusictrack))
25271 music_stop();
25272 }
25273
3/4
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1908 times.
1910 else if (DMaps[tmpscr->tilewarpdmap[index]].midi != (currmidi - ZC_MIDI_COUNT + 4) &&
25274 1908 TheMaps[(DMaps[tdm].map * MAPSCRS + (tmpscr[t].tilewarpscr[index] + DMaps[tdm].xoff))].screen_midi != (currmidi - ZC_MIDI_COUNT + 4))
25275 1908 music_stop();
25276 1910 }
25277 }
25278
25279 2865 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25280
5/6
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 1910 times.
✓ Branch 2 taken 486 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 486 times.
2865 bool opening = (tmpscr[t].tilewarptype[index]<=wtPASS && !(DMaps[currdmap].flags&dmfCAVES && tmpscr[t].tilewarptype[index]==wtCAVE)
25281 2396 ? false : COOLSCROLL);
25282
25283 2865 FFCore.warpScriptCheck();
25284 2865 draw_screen(tmpscr);
25285 2865 advanceframe(true);
25286
25287 2865 skippedaframe=true;
25288
25289
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 2444 times.
2865 if(type==cCAVE2) walkup2(opening);
25290
2/2
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 456 times.
2444 else if(type==cCAVE) walkdown(opening);
25291 2865 }
25292
25293
2/2
✓ Branch 0 taken 2900 times.
✓ Branch 1 taken 952 times.
3852 if(type==cPIT)
25294 {
25295 952 didpit=true;
25296 952 pitx=x;
25297 952 pity=y;
25298 952 warp_sound = warpsfx2;
25299 952 }
25300
25301
5/6
✓ Branch 0 taken 1293 times.
✓ Branch 1 taken 2559 times.
✓ Branch 2 taken 1236 times.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
3909 if(DMaps[currdmap].flags&dmf3STAIR && (currscr==129 || !(DMaps[currdmap].flags&dmfGUYCAVES))
25302
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
1293 && tmpscr[specialcave > 0 && DMaps[currdmap].flags&dmfGUYCAVES ? 1:0].room==rWARP && type==cSTAIR)
25303 {
25304
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(!skippedaframe)
25305 {
25306 FFCore.warpScriptCheck();
25307 draw_screen(tmpscr);
25308 advanceframe(true);
25309 }
25310
25311 // "take any road you want"
25312
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 11 times.
57 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
25313 57 int32_t code = WARPCODE(currdmap,homescr,dw);
25314
25315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(code>-1)
25316 {
25317 57 bool changedlevel = false;
25318 57 bool changeddmap = false;
25319
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 15 times.
57 if(currdmap != code>>8)
25320 {
25321 15 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25322 15 changeddmap = true;
25323 15 }
25324
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(dlevel != DMaps[code>>8].level)
25325 {
25326 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25327 changedlevel = true;
25328 }
25329 57 currdmap = code>>8;
25330 57 dlevel = DMaps[currdmap].level;
25331
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 15 times.
57 if(changeddmap)
25332 {
25333 15 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25334 15 }
25335
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(changedlevel)
25336 {
25337 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25338 }
25339
25340 57 currmap = DMaps[currdmap].map;
25341 57 homescr = (code&0xFF) + DMaps[currdmap].xoff;
25342 57 init_dmap();
25343
25344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(canPermSecret())
25345 57 setmapflag(mSECRET);
25346 57 }
25347
25348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(specialcave==STAIRCAVE) exitcave();
25349
25350 57 return;
25351 }
25352
25353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3795 times.
3795 if(type==cRESET)
25354 {
25355 if(!skippedaframe)
25356 {
25357 FFCore.warpScriptCheck();
25358 draw_screen(tmpscr);
25359 advanceframe(true);
25360 }
25361
25362 if(!(tmpscr->noreset&mSECRET)) unsetmapflag(mSECRET);
25363
25364 if(!(tmpscr->noreset&mITEM)) unsetmapflag(mITEM);
25365
25366 if(!(tmpscr->noreset&mSPECIALITEM)) unsetmapflag(mSPECIALITEM);
25367
25368 if(!(tmpscr->noreset&mNEVERRET)) unsetmapflag(mNEVERRET);
25369
25370 if(!(tmpscr->noreset&mCHEST)) unsetmapflag(mCHEST);
25371
25372 if(!(tmpscr->noreset&mLOCKEDCHEST)) unsetmapflag(mLOCKEDCHEST);
25373
25374 if(!(tmpscr->noreset&mBOSSCHEST)) unsetmapflag(mBOSSCHEST);
25375
25376 if(!(tmpscr->noreset&mLOCKBLOCK)) unsetmapflag(mLOCKBLOCK);
25377
25378 if(!(tmpscr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(mBOSSLOCKBLOCK);
25379
25380 if(isdungeon())
25381 {
25382 if(!(tmpscr->noreset&mDOOR_LEFT)) unsetmapflag(mDOOR_LEFT);
25383
25384 if(!(tmpscr->noreset&mDOOR_RIGHT)) unsetmapflag(mDOOR_RIGHT);
25385
25386 if(!(tmpscr->noreset&mDOOR_DOWN)) unsetmapflag(mDOOR_DOWN);
25387
25388 if(!(tmpscr->noreset&mDOOR_UP)) unsetmapflag(mDOOR_UP);
25389 }
25390
25391 didpit=true;
25392 pitx=x;
25393 pity=y;
25394 sdir=dir;
25395 dowarp(4,0, warpsfx2);
25396 }
25397 else
25398 {
25399
3/4
✓ Branch 0 taken 987 times.
✓ Branch 1 taken 2808 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 987 times.
3795 if(!skippedaframe && (tmpscr[t].tilewarptype[index]!=wtNOWARP))
25400 {
25401 987 FFCore.warpScriptCheck();
25402 987 draw_screen(tmpscr);
25403 987 advanceframe(true);
25404 987 }
25405
25406 3795 sdir = dir;
25407 3795 dowarp(0,index, warpsfx2);
25408 }
25409 14092846 }
25410
25411 112 int32_t selectWlevel(int32_t d)
25412 {
25413
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(TriforceCount()==0)
25414 return 0;
25415
25416 112 word l = game->get_wlevel();
25417
25418 112 do
25419 {
25420
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
185 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
25421 break;
25422
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 72 times.
185 else if(d<0)
25423
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 14 times.
72 l = (l==0) ? 7 : l-1;
25424 else
25425
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 97 times.
113 l = (l==7) ? 0 : l+1;
25426
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 112 times.
185 }
25427 185 while(!(game->lvlitems[l+1] & liTRIFORCE));
25428
25429 112 game->set_wlevel(l);
25430 112 return l;
25431 112 }
25432
25433 // Would someone tell the Dodongos to shut their yaps?!
25434 28487 void kill_enemy_sfx()
25435 {
25436
2/2
✓ Branch 0 taken 28487 times.
✓ Branch 1 taken 55297 times.
83784 for(int32_t i=0; i<guys.Count(); i++)
25437 {
25438
2/2
✓ Branch 0 taken 20392 times.
✓ Branch 1 taken 34905 times.
55297 if(((enemy*)guys.spr(i))->bgsfx)
25439 34905 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
25440 55297 }
25441
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 28376 times.
28487 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
25442
2/2
✓ Branch 0 taken 28471 times.
✓ Branch 1 taken 16 times.
28487 if(tmpscr->room==rGANON)
25443 16 stop_sfx(WAV_ROAR);
25444 28487 }
25445
25446 3271 bool HeroClass::HasHeavyBoots()
25447 {
25448
2/2
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 837376 times.
840647 for ( int32_t q = 0; q < MAXITEMS; ++q )
25449 {
25450
3/6
✓ Branch 0 taken 68711 times.
✓ Branch 1 taken 768665 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68711 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
837376 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&ITEM_FLAG2) ) return true;
25451 837376 }
25452 3271 return false;
25453 3271 }
25454
25455 7226 bool HeroClass::dowarp(int32_t type, int32_t index, int32_t warpsfx)
25456 {
25457 7226 byte reposition_sword_postwarp = 0;
25458
1/2
✓ Branch 0 taken 7226 times.
✗ Branch 1 not taken.
7226 if(index<0)
25459 {
25460 return false;
25461 }
25462 7226 is_warping = true;
25463
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 7226 times.
7981 for ( int32_t q = 0; q < Lwpns.Count(); ++q )
25464 {
25465 755 weapon *swd=NULL;
25466 755 swd = (weapon*)Lwpns.spr(q);
25467
2/2
✓ Branch 0 taken 685 times.
✓ Branch 1 taken 70 times.
755 if(swd->id == (attack==wSword ? wSword : wWand))
25468 {
25469 70 Lwpns.del(q);
25470 70 }
25471 755 }
25472
25473 7226 attackclk = charging = spins = tapping = 0;
25474 7226 attack = none;
25475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7226 times.
7226 if ( warp_sound > 0 ) warpsfx = warp_sound;
25476 7226 warp_sound = 0;
25477 7226 word wdmap=0;
25478 7226 byte wscr=0,wtype=0,t=0;
25479 7226 bool overlay=false;
25480 7226 t=(currscr<128)?0:1;
25481 7226 int32_t wrindex = 0;
25482 7226 bool wasSideview = isSideViewGravity(t); // (tmpscr[t].flags7 & fSIDEVIEW)!=0 && !ignoreSideview;
25483
25484 // Drawing commands probably shouldn't carry over...
25485
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 6842 times.
7226 if ( !get_qr(qr_SCRIPTDRAWSINWARPS) )
25486 6842 script_drawing_commands.Clear();
25487
25488
4/6
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 3838 times.
✓ Branch 2 taken 2893 times.
✓ Branch 3 taken 111 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7226 switch(type)
25489 {
25490 case 0: // tile warp
25491 3838 wtype = tmpscr[t].tilewarptype[index];
25492 3838 wdmap = tmpscr[t].tilewarpdmap[index];
25493 3838 wscr = tmpscr[t].tilewarpscr[index];
25494 3838 overlay = get_bit(&tmpscr[t].tilewarpoverlayflags,index)?1:0;
25495 3838 wrindex=(tmpscr->warpreturnc>>(index*2))&3;
25496 3838 break;
25497
25498 case 1: // side warp
25499 2893 wtype = tmpscr[t].sidewarptype[index];
25500 2893 wdmap = tmpscr[t].sidewarpdmap[index];
25501 2893 wscr = tmpscr[t].sidewarpscr[index];
25502 2893 overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
25503 2893 wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
25504 //tmpscr->doscript = 0; //kill the currebt screen's script so that it does not continue to run during the scroll.
25505 //there is no doscript for screen scripts. They run like ffcs.
25506
25507 2893 break;
25508
25509 case 2: // whistle warp
25510 {
25511 111 wtype = wtWHISTLE;
25512
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
25513 111 int32_t level=0;
25514
25515
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(blowcnt==0)
25516 level = selectWlevel(0);
25517 else
25518 {
25519
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 111 times.
223 for(int32_t i=0; i<abs(blowcnt); i++)
25520 112 level = selectWlevel(blowcnt);
25521 }
25522
25523
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
25524 {
25525 level %= QMisc.warp[wind].size;
25526 game->set_wlevel(level);
25527 }
25528
25529 111 wdmap = QMisc.warp[wind].dmap[level];
25530 111 wscr = QMisc.warp[wind].scr[level];
25531 }
25532 111 break;
25533
25534 case 3:
25535 wtype = wtIWARP;
25536 wdmap = cheat_goto_dmap;
25537 wscr = cheat_goto_screen;
25538 break;
25539
25540 case 4:
25541 wtype = wtIWARP;
25542 wdmap = currdmap;
25543 wscr = homescr-DMaps[currdmap].xoff;
25544 break;
25545 }
25546
25547 7226 bool intradmap = (wdmap == currdmap);
25548 7226 int32_t olddmap = currdmap;
25549 7226 rehydratelake(type!=wtSCROLL);
25550 7226 bool updatemusic = FFCore.can_dmap_change_music(wdmap);
25551 7226 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
25552 7226 bool musicrevert = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_REVERT;
25553
25554
7/8
✓ Branch 0 taken 3582 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 583 times.
✓ Branch 3 taken 322 times.
✓ Branch 4 taken 1636 times.
✓ Branch 5 taken 841 times.
✓ Branch 6 taken 111 times.
✓ Branch 7 taken 151 times.
7226 switch(wtype)
25555 {
25556 case wtCAVE:
25557 {
25558 // cave/item room
25559 583 ALLOFF();
25560 583 homescr=currscr;
25561 583 currscr=0x80;
25562
25563
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 154 times.
583 if(DMaps[currdmap].flags&dmfCAVES) // cave
25564 {
25565
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
429 if (updatemusic || !musicnocut || !get_qr(qr_SCREEN80_OWN_MUSIC))
25566 429 music_stop();
25567 429 kill_sfx();
25568
25569
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 367 times.
429 if(tmpscr->room==rWARP)
25570 {
25571 62 currscr=0x81;
25572 62 specialcave = STAIRCAVE;
25573 62 }
25574 367 else specialcave = GUYCAVE;
25575
25576 //lighting(2,dir);
25577 429 lighting(false, true);
25578 429 loadlvlpal(10);
25579
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 63 times.
795 bool b2 = COOLSCROLL&&
25580
3/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 159 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
366 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
25581
2/4
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
207 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
25582
2/4
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
207 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
25583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
207 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
25584 429 blackscr(30,b2?false:true);
25585 429 loadscr(0,wdmap,currscr,up,false);
25586 429 loadscr(1,wdmap,homescr,up,false);
25587 //preloaded freeform combos
25588 429 ffscript_engine(true);
25589 429 putscr(scrollbuf,0,0,tmpscr);
25590 429 putscrdoors(scrollbuf,0,0,tmpscr);
25591 429 dir=up;
25592 429 x=112;
25593 429 y=160;
25594
1/2
✓ Branch 0 taken 429 times.
✗ Branch 1 not taken.
429 if(didpit)
25595 {
25596 didpit=false;
25597 x=pitx;
25598 y=pity;
25599 }
25600
25601 429 reset_hookshot();
25602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
429 if(reposition_sword_postwarp)
25603 {
25604 weapon *swd=NULL;
25605 for(int32_t i=0; i<Lwpns.Count(); i++)
25606 {
25607 swd = (weapon*)Lwpns.spr(i);
25608
25609 if(swd->id == (attack==wSword ? wSword : wWand))
25610 {
25611 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25612 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25613 positionSword(swd,item_id);
25614 break;
25615 }
25616 }
25617 }
25618 429 stepforward(diagonalMovement?5:6, false);
25619 429 }
25620 else // item room
25621 {
25622 154 specialcave = ITEMCELLAR;
25623 154 map_bkgsfx(false);
25624 154 kill_enemy_sfx();
25625 154 draw_screen(tmpscr,false);
25626
25627 //unless the room is already dark, fade to black
25628
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 153 times.
154 if (!get_qr(qr_NEW_DARKROOM))
25629 {
25630
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 152 times.
153 if(!darkroom)
25631 {
25632 152 darkroom = true;
25633 152 fade(DMaps[currdmap].color,true,false);
25634 152 }
25635 153 }
25636 else
25637 1 fade(DMaps[currdmap].color, true, false);
25638
25639 154 blackscr(30,true);
25640 154 loadscr(0,wdmap,currscr,down,false);
25641 154 loadscr(1,wdmap,homescr,-1,false);
25642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if ( dontdraw < 2 ) { dontdraw=1; }
25643 154 draw_screen(tmpscr, false);
25644 154 fade(0xB,true,true);
25645 154 darkroom = false;
25646 154 dir=down;
25647 154 x=48;
25648 154 y=0;
25649
25650 // is this didpit check necessary?
25651
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 1 times.
154 if(didpit)
25652 {
25653 1 didpit=false;
25654 1 x=pitx;
25655 1 y=pity;
25656 1 }
25657
25658 154 reset_hookshot();
25659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if(reposition_sword_postwarp)
25660 {
25661 weapon *swd=NULL;
25662 for(int32_t i=0; i<Lwpns.Count(); i++)
25663 {
25664 swd = (weapon*)Lwpns.spr(i);
25665
25666 if(swd->id == (attack==wSword ? wSword : wWand))
25667 {
25668 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25669 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25670 positionSword(swd,item_id);
25671 break;
25672 }
25673 }
25674 }
25675 154 lighting(false, true);
25676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if ( dontdraw < 2 ) { dontdraw=0; }
25677 154 stepforward(diagonalMovement?16:18, false);
25678 }
25679
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 583 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
583 if (get_qr(qr_SCREEN80_OWN_MUSIC) && (updatemusic || !musicnocut))
25680 {
25681 playLevelMusic();
25682 if (musicrevert)
25683 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
25684 }
25685 583 break;
25686 }
25687
25688 case wtPASS: // passageway
25689 {
25690 322 map_bkgsfx(false);
25691 322 kill_enemy_sfx();
25692 322 ALLOFF();
25693 //play sound
25694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
25695 322 homescr=currscr;
25696 322 currscr=0x81;
25697 322 specialcave = PASSAGEWAY;
25698 322 byte warpscr2 = wscr + DMaps[wdmap].xoff;
25699 322 draw_screen(tmpscr,false);
25700
25701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(!get_qr(qr_NEW_DARKROOM))
25702 {
25703
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 314 times.
322 if(!darkroom)
25704 314 fade(DMaps[currdmap].color,true,false);
25705
25706 322 darkroom=true;
25707 322 }
25708 else
25709 fade(DMaps[currdmap].color,true,false);
25710 322 blackscr(30,true);
25711 322 loadscr(0,wdmap,currscr,down,false);
25712 322 loadscr(1,wdmap,homescr,-1,false);
25713 //preloaded freeform combos
25714 322 ffscript_engine(true);
25715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if ( dontdraw < 2 ) { dontdraw=1; }
25716 322 draw_screen(tmpscr, false);
25717 322 lighting(false, true);
25718
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if (get_qr(qr_NEW_DARKROOM))
25719 fade(0xB, false, true);
25720 322 dir=down;
25721 322 x=48;
25722
25723
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 174 times.
322 if((homescr&15) > (warpscr2&15))
25724 {
25725 174 x=192;
25726 174 }
25727
25728
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 12 times.
322 if((homescr&15) == (warpscr2&15))
25729 {
25730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if((currscr>>4) > (warpscr2>>4))
25731 {
25732 12 x=192;
25733 12 }
25734 12 }
25735
25736 // is this didpit check necessary?
25737
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if(didpit)
25738 {
25739 didpit=false;
25740 x=pitx;
25741 y=pity;
25742 }
25743
25744 322 y=0;
25745 322 set_respawn_point();
25746 322 trySideviewLadder();
25747 322 reset_hookshot();
25748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(reposition_sword_postwarp)
25749 {
25750 weapon *swd=NULL;
25751 for(int32_t i=0; i<Lwpns.Count(); i++)
25752 {
25753 swd = (weapon*)Lwpns.spr(i);
25754
25755 if(swd->id == (attack==wSword ? wSword : wWand))
25756 {
25757 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25758 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25759 positionSword(swd,item_id);
25760 break;
25761 }
25762 }
25763 }
25764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if ( dontdraw < 2 ) { dontdraw=0; }
25765 322 stepforward(diagonalMovement?16:18, false);
25766 322 newscr_clk=frame;
25767 322 activated_timed_warp=false;
25768 322 stepoutindex=index;
25769 322 stepoutscr = warpscr2;
25770 322 stepoutdmap = wdmap;
25771 322 stepoutwr=wrindex;
25772 }
25773 322 break;
25774
25775 case wtEXIT: // entrance/exit
25776 {
25777 1636 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
25778 1636 ALLOFF();
25779
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1636 if(updatemusic||!musicnocut)
25780 1636 music_stop();
25781 1636 kill_sfx();
25782 1636 blackscr(30,false);
25783 1636 bool changedlevel = false;
25784 1636 bool changeddmap = false;
25785
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1633 times.
1636 if(currdmap != wdmap)
25786 {
25787 1633 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25788 1633 changeddmap = true;
25789 1633 }
25790
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 1374 times.
1636 if(dlevel != DMaps[wdmap].level)
25791 {
25792 1374 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25793 1374 changedlevel = true;
25794 1374 }
25795 1636 dlevel = DMaps[wdmap].level;
25796 1636 currdmap = wdmap;
25797
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1633 times.
1636 if(changeddmap)
25798 {
25799 1633 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25800 1633 }
25801
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 1374 times.
1636 if(changedlevel)
25802 {
25803 1374 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25804 1374 }
25805
25806 1636 currmap=DMaps[currdmap].map;
25807 1636 init_dmap();
25808 1636 update_subscreens(wdmap);
25809 1636 loadfullpal();
25810 1636 ringcolor(false);
25811 1636 loadlvlpal(DMaps[currdmap].color);
25812 //lastentrance_dmap = currdmap;
25813 1636 homescr = currscr = wscr + DMaps[currdmap].xoff;
25814 1636 loadscr(0,currdmap,currscr,-1,overlay);
25815
25816
4/4
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1580 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 10 times.
1636 if((tmpscr->flags&fDARK) && !get_qr(qr_NEW_DARKROOM))
25817 {
25818
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 if(get_qr(qr_FADE))
25819 {
25820 7 interpolatedfade();
25821 7 }
25822 else
25823 {
25824 3 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
25825 }
25826
25827 10 darkroom=naturaldark=true;
25828 10 }
25829 else
25830 {
25831 1626 darkroom=naturaldark=false;
25832 }
25833
25834 int32_t wrx,wry;
25835
25836
2/2
✓ Branch 0 taken 655 times.
✓ Branch 1 taken 981 times.
1636 if(get_qr(qr_NOARRIVALPOINT))
25837 {
25838 655 wrx=tmpscr->warpreturnx[0];
25839 655 wry=tmpscr->warpreturny[0];
25840 655 }
25841 else
25842 {
25843 981 wrx=tmpscr->warparrivalx;
25844 981 wry=tmpscr->warparrivaly;
25845 }
25846
25847
6/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 1545 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 1573 times.
1636 if(((wrx>0||wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
25848 {
25849
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 460 times.
1573 if(dlevel)
25850 {
25851 1113 lastentrance = currscr;
25852 1113 }
25853 else
25854 {
25855 460 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
25856 }
25857
25858 1573 lastentrance_dmap = wdmap;
25859 1573 }
25860
25861
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 523 times.
1636 if(dlevel)
25862 {
25863
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 554 times.
1113 if(get_qr(qr_NOARRIVALPOINT))
25864 {
25865 559 x=tmpscr->warpreturnx[wrindex];
25866 559 y=tmpscr->warpreturny[wrindex];
25867 559 }
25868 else
25869 {
25870 554 x=tmpscr->warparrivalx;
25871 554 y=tmpscr->warparrivaly;
25872 }
25873 1113 }
25874 else
25875 {
25876 523 x=tmpscr->warpreturnx[wrindex];
25877 523 y=tmpscr->warpreturny[wrindex];
25878 }
25879
25880
2/2
✓ Branch 0 taken 1627 times.
✓ Branch 1 taken 9 times.
1636 if(didpit)
25881 {
25882 9 didpit=false;
25883 9 x=pitx;
25884 9 y=pity;
25885 9 }
25886
25887 1636 dir=down;
25888
25889
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 1608 times.
1636 if(x==0) dir=right;
25890
25891
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1613 times.
1636 if(x==240) dir=left;
25892
25893
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1598 times.
1636 if(y==0) dir=down;
25894
25895
2/2
✓ Branch 0 taken 628 times.
✓ Branch 1 taken 1008 times.
1636 if(y==160) dir=up;
25896
25897
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 523 times.
1636 if(dlevel)
25898 {
25899 // reset enemy kill counts
25900
2/2
✓ Branch 0 taken 142464 times.
✓ Branch 1 taken 1113 times.
143577 for(int32_t i=0; i<128; i++)
25901 {
25902 142464 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
25903 142464 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
25904 142464 }
25905 1113 }
25906
25907 1636 markBmap(dir^1);
25908 //preloaded freeform combos
25909 1636 ffscript_engine(true);
25910
25911 1636 reset_hookshot();
25912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
1636 if(reposition_sword_postwarp)
25913 {
25914 weapon *swd=NULL;
25915 for(int32_t i=0; i<Lwpns.Count(); i++)
25916 {
25917 swd = (weapon*)Lwpns.spr(i);
25918
25919 if(swd->id == (attack==wSword ? wSword : wWand))
25920 {
25921 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25922 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25923 positionSword(swd,item_id);
25924 break;
25925 }
25926 }
25927 }
25928
25929
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 1163 times.
1636 if(isdungeon())
25930 {
25931 473 openscreen();
25932
4/4
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 374 times.
473 if(get_er(er_SHORTDGNWALK)==0 && get_qr(qr_SHORTDGNWALK)==0)
25933 374 stepforward(diagonalMovement?11:12, false);
25934 else
25935 // Didn't walk as far pre-1.93, and some quests depend on that
25936 99 stepforward(8, false);
25937 473 }
25938 else
25939 {
25940
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 996 times.
1163 if(!COOLSCROLL)
25941 167 openscreen();
25942
25943 1163 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
25944 1163 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
25945 1163 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
25946
25947
10/10
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1004 times.
✓ Branch 5 taken 38 times.
✓ Branch 6 taken 27 times.
✓ Branch 7 taken 977 times.
✓ Branch 8 taken 27 times.
✓ Branch 9 taken 54 times.
1163 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
25948 {
25949 204 reset_pal_cycling();
25950 204 putscr(scrollbuf,0,0,tmpscr);
25951 204 putscrdoors(scrollbuf,0,0,tmpscr);
25952 204 walkup(COOLSCROLL);
25953 204 }
25954
10/10
✓ Branch 0 taken 1001 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 951 times.
✓ Branch 4 taken 905 times.
✓ Branch 5 taken 76 times.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 881 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 25 times.
1031 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
25955 {
25956 157 reset_pal_cycling();
25957 157 putscr(scrollbuf,0,0,tmpscr);
25958 157 putscrdoors(scrollbuf,0,0,tmpscr);
25959 157 walkdown2(COOLSCROLL);
25960 157 }
25961
2/2
✓ Branch 0 taken 852 times.
✓ Branch 1 taken 52 times.
906 else if(COOLSCROLL)
25962 {
25963 852 openscreen();
25964 852 }
25965 }
25966
25967 1678 show_subscreen_life=true;
25968 1678 show_subscreen_numbers=true;
25969
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1678 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 43 times.
1678 if (updatemusic || !musicnocut)
25970 {
25971 1721 playLevelMusic();
25972
1/2
✓ Branch 0 taken 1635 times.
✗ Branch 1 not taken.
1721 if (musicrevert)
25973 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
25974 1635 }
25975 1678 currcset=DMaps[currdmap].color;
25976 1678 dointro();
25977 1678 set_respawn_point();
25978 1678 trySideviewLadder();
25979
25980
2/2
✓ Branch 0 taken 9810 times.
✓ Branch 1 taken 1678 times.
11488 for(int32_t i=0; i<6; i++)
25981 9810 visited[i]=-1;
25982
25983 1678 break;
25984 }
25985
25986 case wtSCROLL: // scrolling warp
25987 {
25988 841 int32_t c = DMaps[currdmap].color;
25989 841 scrolling_map = currmap;
25990 841 currmap = DMaps[wdmap].map;
25991 841 update_subscreens(wdmap);
25992
25993 841 dlevel = DMaps[wdmap].level;
25994 //check if Hero has the map for the new location before updating the subscreen. ? -Z
25995 //This works only in one direction, if Hero had a map, to not having one.
25996 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
25997 841 update_subscreens(wdmap);
25998
25999 /*if ( has_item(itype_map, dlevel) )
26000 {
26001 //Blank the map during an intra-dmap scrolling warp.
26002 dlevel = -1; //a hack for the minimap. This works!! -Z
26003 }*/
26004
26005 // fix the scrolling direction, if it was a tile or instant warp
26006
2/4
✓ Branch 0 taken 841 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 841 times.
841 if(type==0 || type>=3)
26007 {
26008 sdir = dir;
26009 }
26010
26011 841 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
26012 //dlevel = DMaps[wdmap].level; //Fix dlevel and draw the map (end hack). -Z
26013
26014 841 reset_hookshot();
26015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 841 times.
841 if(reposition_sword_postwarp)
26016 {
26017 weapon *swd=NULL;
26018 for(int32_t i=0; i<Lwpns.Count(); i++)
26019 {
26020 swd = (weapon*)Lwpns.spr(i);
26021
26022 if(swd->id == (attack==wSword ? wSword : wWand))
26023 {
26024 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26025 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26026 positionSword(swd,item_id);
26027 break;
26028 }
26029 }
26030 }
26031
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 752 times.
841 if(!intradmap)
26032 {
26033 752 homescr = currscr = wscr + DMaps[wdmap].xoff;
26034 752 init_dmap();
26035
26036 int32_t wrx,wry;
26037
26038
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 338 times.
752 if(get_qr(qr_NOARRIVALPOINT))
26039 {
26040 414 wrx=tmpscr->warpreturnx[0];
26041 414 wry=tmpscr->warpreturny[0];
26042 414 }
26043 else
26044 {
26045 338 wrx=tmpscr->warparrivalx;
26046 338 wry=tmpscr->warparrivaly;
26047 }
26048
26049
8/8
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 425 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 286 times.
✓ Branch 5 taken 466 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 274 times.
752 if(((wrx>0||wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!get_qr(qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
26050 {
26051
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 199 times.
274 if(dlevel)
26052 {
26053 75 lastentrance = currscr;
26054 75 }
26055 else
26056 {
26057 199 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
26058 }
26059
26060 274 lastentrance_dmap = wdmap;
26061 274 }
26062 752 }
26063
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 453 times.
841 if(DMaps[currdmap].color != c)
26064 {
26065 453 lighting(false, true);
26066 453 }
26067
26068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 841 times.
841 if (updatemusic)
26069 {
26070 841 playLevelMusic();
26071
1/2
✓ Branch 0 taken 841 times.
✗ Branch 1 not taken.
841 if (musicrevert)
26072 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26073 841 }
26074 841 currcset=DMaps[currdmap].color;
26075 841 dointro();
26076 }
26077 841 break;
26078
26079 case wtWHISTLE: // whistle warp
26080 {
26081 111 scrolling_map = currmap;
26082 111 currmap = DMaps[wdmap].map;
26083 111 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
26084 111 reset_hookshot();
26085 111 currdmap=wdmap;
26086 111 dlevel=DMaps[currdmap].level;
26087 111 lighting(false, true);
26088 111 init_dmap();
26089
26090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if (updatemusic)
26091 {
26092 111 playLevelMusic();
26093
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if (musicrevert)
26094 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26095 111 }
26096 111 currcset=DMaps[currdmap].color;
26097 111 dointro();
26098 111 action=inwind; FFCore.setHeroAction(inwind);
26099 int32_t wry;
26100
26101
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 83 times.
111 if(get_qr(qr_NOARRIVALPOINT))
26102 28 wry=tmpscr->warpreturny[0];
26103 83 else wry=tmpscr->warparrivaly;
26104
26105 int32_t wrx;
26106
26107
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 83 times.
111 if(get_qr(qr_NOARRIVALPOINT))
26108 28 wrx=tmpscr->warpreturnx[0];
26109 83 else wrx=tmpscr->warparrivalx;
26110
26111
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 111 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 111 times.
✓ Branch 10 taken 111 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 111 times.
✗ Branch 13 not taken.
222 Lwpns.add(new weapon((zfix)(index==left?240:index==right?0:wrx),(zfix)(index==down?0:index==up?160:wry),
26112
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1));
26113 111 whirlwind=255;
26114 111 whistleitem=-1;
26115 }
26116 111 break;
26117
26118 case wtIWARP:
26119 case wtIWARPBLK:
26120 case wtIWARPOPEN:
26121 case wtIWARPZAP:
26122 case wtIWARPWAVE: // insta-warps
26123 {
26124 3582 bool old_192 = false;
26125
2/2
✓ Branch 0 taken 3538 times.
✓ Branch 1 taken 44 times.
3582 if (get_qr(qr_192b163_WARP))
26126 {
26127
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if ( wtype == wtIWARPWAVE )
26128 {
26129 wtype = wtIWARPWAVE;
26130 old_192 = true;
26131 }
26132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if ( old_192 )
26133 {
26134 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
26135 didpit=false;
26136 update_subscreens();
26137 warp_sound = 0;
26138 is_warping = false;
26139 return false;
26140 }
26141 44 }
26142 //for determining whether to exit cave
26143 3582 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
26144 3582 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
26145 3582 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
26146
26147
8/8
✓ Branch 0 taken 3185 times.
✓ Branch 1 taken 397 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 3119 times.
✓ Branch 4 taken 3185 times.
✓ Branch 5 taken 66 times.
✓ Branch 6 taken 94 times.
✓ Branch 7 taken 3091 times.
6951 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
26148
8/8
✓ Branch 0 taken 3165 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 3099 times.
✓ Branch 4 taken 65 times.
✓ Branch 5 taken 3164 times.
✓ Branch 6 taken 3107 times.
✓ Branch 7 taken 57 times.
3185 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
26149
26150
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3195 times.
3992 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
26151 {
26152 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
26153 3195 bool wasswimming = (action == swimming);
26154 3195 int32_t olddiveclk = diveclk;
26155 3195 ALLOFF();
26156
26157
2/2
✓ Branch 0 taken 3159 times.
✓ Branch 1 taken 36 times.
3195 if(wasswimming)
26158 {
26159 36 Hero.SetSwim();
26160 36 diveclk = olddiveclk;
26161 36 }
26162
26163 3195 kill_sfx();
26164 3195 }
26165 //play sound
26166
2/2
✓ Branch 0 taken 3103 times.
✓ Branch 1 taken 95 times.
3198 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
26167
2/2
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 2609 times.
3198 if(wtype==wtIWARPZAP)
26168 {
26169 589 zapout();
26170 589 }
26171
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 2386 times.
2609 else if(wtype==wtIWARPWAVE)
26172 {
26173 //only draw Hero if he's not in a cave -DD
26174 223 wavyout(!cavewarp);
26175 223 }
26176
2/2
✓ Branch 0 taken 1479 times.
✓ Branch 1 taken 907 times.
2386 else if(wtype!=wtIWARP)
26177 {
26178
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 612 times.
907 bool b2 = COOLSCROLL&&cavewarp;
26179 907 blackscr(30,b2?false:true);
26180 907 }
26181
26182 3198 int32_t c = DMaps[currdmap].color;
26183 3198 bool changedlevel = false;
26184 3198 bool changeddmap = false;
26185
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 1707 times.
3198 if(currdmap != wdmap)
26186 {
26187 1707 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
26188 1707 changeddmap = true;
26189 1707 }
26190
2/2
✓ Branch 0 taken 2618 times.
✓ Branch 1 taken 580 times.
3198 if(dlevel != DMaps[wdmap].level)
26191 {
26192 580 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
26193 580 changedlevel = true;
26194 580 }
26195 3198 dlevel = DMaps[wdmap].level;
26196 3198 currdmap = wdmap;
26197
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 1707 times.
3198 if(changeddmap)
26198 {
26199 1707 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
26200 1707 }
26201
2/2
✓ Branch 0 taken 2618 times.
✓ Branch 1 taken 580 times.
3198 if(changedlevel)
26202 {
26203 580 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
26204 580 }
26205
26206 3198 currmap = DMaps[currdmap].map;
26207 3198 init_dmap();
26208 3198 update_subscreens(wdmap);
26209
26210 3198 ringcolor(false);
26211
26212
2/2
✓ Branch 0 taken 2334 times.
✓ Branch 1 taken 864 times.
3198 if(DMaps[currdmap].color != c)
26213 864 loadlvlpal(DMaps[currdmap].color);
26214
26215 3198 homescr = currscr = wscr + DMaps[currdmap].xoff;
26216
26217 3198 lightingInstant(); // Also sets naturaldark
26218
26219 3198 loadscr(0,currdmap,currscr,-1,overlay);
26220
26221 3198 x = tmpscr->warpreturnx[wrindex];
26222 3198 y = tmpscr->warpreturny[wrindex];
26223
26224
2/2
✓ Branch 0 taken 1937 times.
✓ Branch 1 taken 1261 times.
3198 if(didpit)
26225 {
26226 1261 didpit=false;
26227 1261 x=pitx;
26228 1261 y=pity;
26229 1261 }
26230
26231 3198 type1 = combobuf[MAPCOMBO(x,y-16)].type;
26232 3198 type2 = combobuf[MAPCOMBO(x,y)].type;
26233 3198 type3 = combobuf[MAPCOMBO(x,y+16)].type;
26234
26235
2/2
✓ Branch 0 taken 3121 times.
✓ Branch 1 taken 77 times.
3198 if(x==0) dir=right;
26236
26237
2/2
✓ Branch 0 taken 3194 times.
✓ Branch 1 taken 4 times.
3198 if(x==240) dir=left;
26238
26239
2/2
✓ Branch 0 taken 3155 times.
✓ Branch 1 taken 43 times.
3198 if(y==0) dir=down;
26240
26241
2/2
✓ Branch 0 taken 3130 times.
✓ Branch 1 taken 68 times.
3198 if(y==160) dir=up;
26242
26243 3198 markBmap(dir^1);
26244
26245 3198 int32_t checkwater = iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
26246
26247
10/16
✓ Branch 0 taken 3169 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 29 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 29 times.
✓ Branch 12 taken 29 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 3169 times.
3227 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
26248 {
26249 29 hopclk=0xFF;
26250 29 SetSwim();
26251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if (!IsSideSwim()) attackclk = charging = spins = 0;
26252 29 }
26253 else
26254 {
26255 3169 action = none; FFCore.setHeroAction(none);
26256 }
26257 //preloaded freeform combos
26258 3198 ffscript_engine(true);
26259
26260 3198 putscr(scrollbuf,0,0,tmpscr);
26261 3198 putscrdoors(scrollbuf,0,0,tmpscr);
26262
26263
10/10
✓ Branch 0 taken 3186 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 3120 times.
✓ Branch 4 taken 3186 times.
✓ Branch 5 taken 66 times.
✓ Branch 6 taken 79 times.
✓ Branch 7 taken 3107 times.
✓ Branch 8 taken 168 times.
✓ Branch 9 taken 247 times.
3198 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
26264 {
26265 312 reset_pal_cycling();
26266 312 putscr(scrollbuf,0,0,tmpscr);
26267 312 putscrdoors(scrollbuf,0,0,tmpscr);
26268 312 walkup(COOLSCROLL);
26269 312 }
26270
9/10
✓ Branch 0 taken 3186 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 3099 times.
✓ Branch 4 taken 3183 times.
✓ Branch 5 taken 84 times.
✓ Branch 6 taken 75 times.
✓ Branch 7 taken 3108 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 75 times.
3354 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
26271 {
26272 339 reset_pal_cycling();
26273 339 putscr(scrollbuf,0,0,tmpscr);
26274 339 putscrdoors(scrollbuf,0,0,tmpscr);
26275 339 walkdown2(COOLSCROLL);
26276 339 }
26277
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 2596 times.
3183 else if(wtype==wtIWARPZAP)
26278 {
26279 587 zapin();
26280 587 }
26281
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 2376 times.
2596 else if(wtype==wtIWARPWAVE)
26282 {
26283 220 wavyin();
26284 220 }
26285
2/2
✓ Branch 0 taken 2242 times.
✓ Branch 1 taken 134 times.
2376 else if(wtype==wtIWARPOPEN)
26286 {
26287 134 openscreen();
26288 134 }
26289
1/2
✓ Branch 0 taken 3498 times.
✗ Branch 1 not taken.
3498 if(reposition_sword_postwarp)
26290 {
26291 weapon *swd=NULL;
26292 for(int32_t i=0; i<Lwpns.Count(); i++)
26293 {
26294 swd = (weapon*)Lwpns.spr(i);
26295
26296 if(swd->id == (attack==wSword ? wSword : wWand))
26297 {
26298 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26299 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26300 positionSword(swd,item_id);
26301 break;
26302 }
26303 }
26304 }
26305 3498 show_subscreen_life=true;
26306 3498 show_subscreen_numbers=true;
26307
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3198 times.
3498 if (updatemusic)
26308 {
26309 3198 playLevelMusic();
26310
1/2
✓ Branch 0 taken 3198 times.
✗ Branch 1 not taken.
3198 if (musicrevert)
26311 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26312 3198 }
26313 3498 currcset=DMaps[currdmap].color;
26314 3498 dointro();
26315 3498 set_respawn_point();
26316 3498 trySideviewLadder();
26317 }
26318 3498 break;
26319
26320
26321 case wtNOWARP:
26322 {
26323 151 bool old_192 = false;
26324
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if (get_qr(qr_192b163_WARP))
26325 {
26326 wtype = wtIWARPWAVE;
26327 old_192 = true;
26328 }
26329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if ( old_192 )
26330 {
26331 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
26332 //for determining whether to exit cave
26333 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
26334 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
26335 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
26336
26337 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
26338 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
26339
26340 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
26341 {
26342 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
26343 bool wasswimming = (action == swimming);
26344 int32_t olddiveclk = diveclk;
26345 ALLOFF();
26346
26347 if(wasswimming)
26348 {
26349 Hero.SetSwim();
26350 diveclk = olddiveclk;
26351 }
26352
26353 kill_sfx();
26354 }
26355 //play sound
26356 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
26357 if(wtype==wtIWARPZAP)
26358 {
26359 zapout();
26360 }
26361 else if(wtype==wtIWARPWAVE)
26362 {
26363 //only draw Hero if he's not in a cave -DD
26364 wavyout(!cavewarp);
26365 }
26366 else if(wtype!=wtIWARP)
26367 {
26368 bool b2 = COOLSCROLL&&cavewarp;
26369 blackscr(30,b2?false:true);
26370 }
26371
26372 int32_t c = DMaps[currdmap].color;
26373 bool changedlevel = false;
26374 bool changeddmap = false;
26375 if(currdmap != wdmap)
26376 {
26377 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
26378 changeddmap = true;
26379 }
26380 if(dlevel != DMaps[wdmap].level)
26381 {
26382 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
26383 changedlevel = true;
26384 }
26385 dlevel = DMaps[wdmap].level;
26386 currdmap = wdmap;
26387 if(changeddmap)
26388 {
26389 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
26390 }
26391 if(changedlevel)
26392 {
26393 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
26394 }
26395 currmap = DMaps[currdmap].map;
26396 init_dmap();
26397 update_subscreens(wdmap);
26398
26399 ringcolor(false);
26400
26401 if(DMaps[currdmap].color != c)
26402 loadlvlpal(DMaps[currdmap].color);
26403
26404 homescr = currscr = wscr + DMaps[currdmap].xoff;
26405
26406 lightingInstant(); // Also sets naturaldark
26407
26408 loadscr(0,currdmap,currscr,-1,overlay);
26409
26410 x = tmpscr->warpreturnx[wrindex];
26411 y = tmpscr->warpreturny[wrindex];
26412
26413 if(didpit)
26414 {
26415 didpit=false;
26416 x=pitx;
26417 y=pity;
26418 }
26419
26420 type1 = combobuf[MAPCOMBO(x,y-16)].type;
26421 type2 = combobuf[MAPCOMBO(x,y)].type;
26422 type3 = combobuf[MAPCOMBO(x,y+16)].type;
26423
26424 if(x==0) dir=right;
26425
26426 if(x==240) dir=left;
26427
26428 if(y==0) dir=down;
26429
26430 if(y==160) dir=up;
26431
26432 markBmap(dir^1);
26433
26434 if(iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+8) && _walkflag(x,y+8,0,SWITCHBLOCK_STATE) && current_item(itype_flippers))
26435 {
26436 hopclk=0xFF;
26437 SetSwim();
26438 if (!IsSideSwim()) attackclk = charging = spins = 0;
26439 }
26440 else
26441 {
26442 action = none;
26443 FFCore.setHeroAction(none);
26444 }
26445 //preloaded freeform combos
26446 ffscript_engine(true);
26447
26448 putscr(scrollbuf,0,0,tmpscr);
26449 putscrdoors(scrollbuf,0,0,tmpscr);
26450
26451 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
26452 {
26453 reset_pal_cycling();
26454 putscr(scrollbuf,0,0,tmpscr);
26455 putscrdoors(scrollbuf,0,0,tmpscr);
26456 walkup(COOLSCROLL);
26457 }
26458 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
26459 {
26460 reset_pal_cycling();
26461 putscr(scrollbuf,0,0,tmpscr);
26462 putscrdoors(scrollbuf,0,0,tmpscr);
26463 walkdown2(COOLSCROLL);
26464 }
26465 else if(wtype==wtIWARPZAP)
26466 {
26467 zapin();
26468 }
26469 else if(wtype==wtIWARPWAVE)
26470 {
26471 wavyin();
26472 }
26473 else if(wtype==wtIWARPOPEN)
26474 {
26475 openscreen();
26476 }
26477 if(reposition_sword_postwarp)
26478 {
26479 weapon *swd=NULL;
26480 for(int32_t i=0; i<Lwpns.Count(); i++)
26481 {
26482 swd = (weapon*)Lwpns.spr(i);
26483
26484 if(swd->id == (attack==wSword ? wSword : wWand))
26485 {
26486 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26487 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26488 positionSword(swd,item_id);
26489 break;
26490 }
26491 }
26492 }
26493 show_subscreen_life=true;
26494 show_subscreen_numbers=true;
26495 playLevelMusic();
26496 currcset=DMaps[currdmap].color;
26497 dointro();
26498 set_respawn_point();
26499 trySideviewLadder();
26500 break;
26501 }
26502 else
26503 {
26504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(reposition_sword_postwarp)
26505 {
26506 weapon *swd=NULL;
26507 for(int32_t i=0; i<Lwpns.Count(); i++)
26508 {
26509 swd = (weapon*)Lwpns.spr(i);
26510
26511 if(swd->id == (attack==wSword ? wSword : wWand))
26512 {
26513 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26514 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26515 positionSword(swd,item_id);
26516 break;
26517 }
26518 }
26519 }
26520 151 didpit=false;
26521 151 update_subscreens();
26522 151 warp_sound = 0;
26523 151 is_warping = false;
26524 151 return false;
26525 }
26526 }
26527 default:
26528 didpit=false;
26529 update_subscreens();
26530 warp_sound = 0;
26531 is_warping = false;
26532 if(reposition_sword_postwarp)
26533 {
26534 weapon *swd=NULL;
26535 for(int32_t i=0; i<Lwpns.Count(); i++)
26536 {
26537 swd = (weapon*)Lwpns.spr(i);
26538
26539 if(swd->id == (attack==wSword ? wSword : wWand))
26540 {
26541 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26542 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26543 positionSword(swd,item_id);
26544 break;
26545 }
26546 }
26547 }
26548 return false;
26549 }
26550
26551 // Stop Hero from drowning!
26552
5/6
✓ Branch 0 taken 6690 times.
✓ Branch 1 taken 343 times.
✓ Branch 2 taken 6690 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 343 times.
✓ Branch 5 taken 6347 times.
7033 if(action==drowning || action==lavadrowning || action==sidedrowning)
26553 {
26554 686 drownclk=0;
26555 686 drownclk=0;
26556 686 action=none; FFCore.setHeroAction(none);
26557 686 }
26558
26559 6347 int32_t checkwater = iswaterex(MAPCOMBO(x,y+(bigHitbox?8:12)), currmap, currscr, -1, x,y+(bigHitbox?8:12));
26560 // But keep him swimming if he ought to be!
26561 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
26562
10/12
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 329 times.
✓ Branch 2 taken 6624 times.
✓ Branch 3 taken 52 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 52 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 49 times.
✓ Branch 10 taken 6966 times.
✓ Branch 11 taken 39 times.
6397 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) || get_qr(qr_DROWN))
26563 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
26564
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
52 && (action!=inwind))
26565 {
26566 39 hopclk=0xFF;
26567 39 SetSwim();
26568 39 }
26569
26570 7005 newscr_clk=frame;
26571 7005 activated_timed_warp=false;
26572 7005 eat_buttons();
26573
26574
2/2
✓ Branch 0 taken 1794 times.
✓ Branch 1 taken 5211 times.
7005 if(wtype!=wtIWARP)
26575 5211 attackclk=0;
26576
26577 7005 didstuff=0;
26578 7005 usecounts.clear();
26579 7005 map_bkgsfx(true);
26580 7005 loadside=dir^1;
26581 7005 whistleclk=-1;
26582
26583
3/4
✓ Branch 0 taken 6685 times.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 7005 times.
✗ Branch 3 not taken.
7005 if((z>0 || fakez>0) && isSideViewHero())
26584 {
26585 y-=z;
26586 y-=fakez;
26587 fakez=0;
26588 z=0;
26589 }
26590
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 6569 times.
7005 else if(!isSideViewHero())
26591 {
26592 6569 fall=0;
26593 6569 fakefall=0;
26594 6569 }
26595
26596 // If warping between top-down and sideview screens,
26597 // fix enemies that are carried over by Full Screen Warp
26598 7005 const bool tmpscr_is_sideview = isSideViewHero();
26599
26600
4/4
✓ Branch 0 taken 6571 times.
✓ Branch 1 taken 434 times.
✓ Branch 2 taken 6542 times.
✓ Branch 3 taken 29 times.
7005 if(!wasSideview && tmpscr_is_sideview)
26601 {
26602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 for(int32_t i=0; i<guys.Count(); i++)
26603 {
26604 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
26605 {
26606 guys.spr(i)->y -= guys.spr(i)->z;
26607 guys.spr(i)->y -= guys.spr(i)->fakez;
26608 guys.spr(i)->z = 0;
26609 guys.spr(i)->fakez = 0;
26610 }
26611
26612 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
26613 guys.spr(i)->yofs += 2;
26614 }
26615 29 }
26616
4/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 6857 times.
✓ Branch 2 taken 92 times.
✓ Branch 3 taken 27 times.
6976 else if(wasSideview && !tmpscr_is_sideview)
26617 {
26618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t i=0; i<guys.Count(); i++)
26619 {
26620 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
26621 guys.spr(i)->yofs -= 2;
26622 }
26623 27 }
26624
26625
6/6
✓ Branch 0 taken 4321 times.
✓ Branch 1 taken 2684 times.
✓ Branch 2 taken 428 times.
✓ Branch 3 taken 3893 times.
✓ Branch 4 taken 273 times.
✓ Branch 5 taken 171 times.
7005 if((DMaps[currdmap].type&dmfCONTINUE) || (currdmap==0&&get_qr(qr_DMAP_0_CONTINUE_BUG)))
26626 {
26627
2/2
✓ Branch 0 taken 1346 times.
✓ Branch 1 taken 1441 times.
2957 if(dlevel)
26628 {
26629 int32_t wrx,wry;
26630
26631
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 820 times.
1346 if(get_qr(qr_NOARRIVALPOINT))
26632 {
26633 526 wrx=tmpscr->warpreturnx[0];
26634 526 wry=tmpscr->warpreturny[0];
26635 526 }
26636 else
26637 {
26638 820 wrx=tmpscr->warparrivalx;
26639 820 wry=tmpscr->warparrivaly;
26640 }
26641
26642
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
1356 if((wtype == wtEXIT)
26643
10/10
✓ Branch 0 taken 954 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 886 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 19 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 35 times.
✓ Branch 8 taken 10 times.
✓ Branch 9 taken 4 times.
1346 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))))
26644 {
26645
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 28 times.
440 if(!(wtype==wtSCROLL)||!(get_qr(qr_NOSCROLLCONTINUE)))
26646 {
26647 412 game->set_continue_scrn(homescr);
26648 //Z_message("continue_scrn = %02X e/e\n",game->get_continue_scrn());
26649 412 }
26650
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 15 times.
28 else if(currdmap != game->get_continue_dmap())
26651 {
26652 15 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
26653 15 }
26654 440 }
26655 else
26656 {
26657
2/2
✓ Branch 0 taken 821 times.
✓ Branch 1 taken 85 times.
906 if(currdmap != game->get_continue_dmap())
26658 {
26659 85 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
26660 //Z_message("continue_scrn = %02X dlevel\n",game->get_continue_scrn());
26661 85 }
26662 }
26663 1346 }
26664 else
26665 {
26666 1441 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
26667 //Z_message("continue_scrn = %02X\n !dlevel\n",game->get_continue_scrn());
26668 }
26669
26670 2787 game->set_continue_dmap(currdmap);
26671 2787 lastentrance_dmap = currdmap;
26672 2787 lastentrance = game->get_continue_scrn();
26673 //Z_message("continue_map = %d\n",game->get_continue_dmap());
26674 2787 }
26675
26676
1/2
✓ Branch 0 taken 6851 times.
✗ Branch 1 not taken.
6851 if(tmpscr->flags4&fAUTOSAVE)
26677 {
26678 save_game(true,0);
26679 }
26680
26681
2/2
✓ Branch 0 taken 6706 times.
✓ Branch 1 taken 145 times.
6851 if(tmpscr->flags6&fCONTINUEHERE)
26682 {
26683 145 lastentrance_dmap = currdmap;
26684 145 lastentrance = homescr;
26685 145 }
26686
26687 6851 update_subscreens();
26688 6851 verifyBothWeapons();
26689
26690
2/2
✓ Branch 0 taken 6268 times.
✓ Branch 1 taken 583 times.
6851 if(wtype==wtCAVE)
26691 {
26692
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 154 times.
583 if(DMaps[currdmap].flags&dmfGUYCAVES)
26693 858 Z_eventlog("Entered %s containing %s.\n",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
26694 429 (char *)moduledata.roomtype_names[tmpscr[1].room]);
26695 else
26696 154 Z_eventlog("Entered %s.",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
26697 583 }
26698 12536 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
26699
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 5785 times.
12053 wtype==wtPASS ? "Passageway" :
26700
2/2
✓ Branch 0 taken 1635 times.
✓ Branch 1 taken 4150 times.
9935 wtype==wtEXIT ? "Entrance/Exit" :
26701
2/2
✓ Branch 0 taken 841 times.
✓ Branch 1 taken 3309 times.
4150 wtype==wtSCROLL ? "Scrolling Warp" :
26702 3309 wtype==wtWHISTLE ? "Whistle Warp" :
26703 "Insta-Warp");
26704
26705 6851 eventlog_mapflags();
26706
1/2
✓ Branch 0 taken 6851 times.
✗ Branch 1 not taken.
6851 if(reposition_sword_postwarp)
26707 {
26708 weapon *swd=NULL;
26709 for(int32_t i=0; i<Lwpns.Count(); i++)
26710 {
26711 swd = (weapon*)Lwpns.spr(i);
26712
26713 if(swd->id == (attack==wSword ? wSword : wWand))
26714 {
26715 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26716 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26717 positionSword(swd,item_id);
26718 break;
26719 }
26720 }
26721 }
26722 6851 FFCore.clear_combo_scripts();
26723
4/4
✓ Branch 0 taken 2365 times.
✓ Branch 1 taken 4486 times.
✓ Branch 2 taken 2167 times.
✓ Branch 3 taken 198 times.
6851 if (!intradmap || get_qr(qr_WARPS_RESTART_DMAPSCRIPT))
26724 {
26725 6653 FFScript::deallocateAllScriptOwned(ScriptType::DMap, olddmap);
26726 6653 FFCore.initZScriptDMapScripts();
26727 6653 FFCore.initZScriptScriptedActiveSubscreen();
26728 6653 }
26729 6851 is_warping = false;
26730
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 262 times.
6851 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
26731 262 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
26732 6851 return true;
26733 7002 }
26734
26735 384 void HeroClass::exitcave()
26736 {
26737 384 bool updatemusic = FFCore.can_dmap_change_music(currdmap);
26738 384 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
26739
26740 384 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
26741 384 currscr=homescr;
26742 384 loadscr(0,currdmap,currscr,255,false); // bogus direction
26743 384 x = tmpscr->warpreturnx[0];
26744 384 y = tmpscr->warpreturny[0];
26745
26746
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(didpit)
26747 {
26748 didpit=false;
26749 x=pitx;
26750 y=pity;
26751 }
26752
26753
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 18 times.
384 if(x+y == 0)
26754 18 x = y = 80;
26755
26756 384 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
26757 384 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
26758 384 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
26759
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 335 times.
735 bool b = COOLSCROLL &&
26760
4/4
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 211 times.
335 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
26761
4/4
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 208 times.
211 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
26762
4/4
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 190 times.
208 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
26763
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 5 times.
190 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
26764 400 ALLOFF();
26765 400 blackscr(30,b?false:true);
26766 400 ringcolor(false);
26767 400 loadlvlpal(DMaps[currdmap].color);
26768 400 lighting(false, true);
26769
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
400 if (updatemusic || !musicnocut)
26770 402 music_stop();
26771 408 kill_sfx();
26772 408 putscr(scrollbuf,0,0,tmpscr);
26773 408 putscrdoors(scrollbuf,0,0,tmpscr);
26774
26775
10/10
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 156 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 235 times.
✓ Branch 4 taken 237 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 232 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 7 times.
408 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
26776 {
26777 165 walkup(COOLSCROLL);
26778 165 }
26779
9/10
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 214 times.
✓ Branch 4 taken 219 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 214 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
239 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
26780 {
26781 22 walkdown2(COOLSCROLL);
26782 22 }
26783
26784 402 show_subscreen_life=true;
26785 402 show_subscreen_numbers=true;
26786
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
402 if (updatemusic || !musicnocut)
26787 402 playLevelMusic();
26788 402 currcset=DMaps[currdmap].color;
26789 402 dointro();
26790 402 newscr_clk=frame;
26791 402 activated_timed_warp=false;
26792 402 dir=down;
26793 402 set_respawn_point();
26794 402 eat_buttons();
26795 402 didstuff=0;
26796 402 usecounts.clear();
26797 402 map_bkgsfx(true);
26798 402 loadside=dir^1;
26799 402 }
26800
26801
26802 11094 void HeroClass::stepforward(int32_t steps, bool adjust)
26803 {
26804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11094 times.
11094 if ( FFCore.nostepforward ) return;
26805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11094 times.
11094 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
26806 11094 zfix tx=x; //temp x
26807 11094 zfix ty=y; //temp y
26808 11094 zfix tstep(0); //temp single step distance
26809 11094 zfix s(0); //calculated step distance for all steps
26810 11094 z3step=2;
26811 11094 int32_t sh=shiftdir;
26812 11094 shiftdir=-1;
26813
26814
2/2
✓ Branch 0 taken 189526 times.
✓ Branch 1 taken 11094 times.
200620 for(int32_t i=steps; i>0; --i)
26815 {
26816
2/2
✓ Branch 0 taken 499 times.
✓ Branch 1 taken 189027 times.
189526 if(diagonalMovement)
26817 {
26818
3/4
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 263 times.
499 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
26819 {
26820 236 tstep = 1.5;
26821 236 }
26822 else
26823 {
26824 263 tstep=z3step;
26825 263 z3step=(z3step%2)+1;
26826 }
26827 499 }
26828 else
26829 {
26830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189027 times.
189027 if(get_qr(qr_NEW_HERO_MOVEMENT))
26831 {
26832 tstep = 1.5;
26833 }
26834 else
26835 {
26836
2/2
✓ Branch 0 taken 105433 times.
✓ Branch 1 taken 83594 times.
189027 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
26837
26838
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 60103 times.
✓ Branch 2 taken 45330 times.
✓ Branch 3 taken 38591 times.
✓ Branch 4 taken 45003 times.
189027 switch(dir)
26839 {
26840 case up:
26841 60103 ty-=tstep;
26842 60103 break;
26843
26844 case down:
26845 45330 ty+=tstep;
26846 45330 break;
26847
26848 case left:
26849 38591 tx-=tstep;
26850 38591 break;
26851
26852 case right:
26853 45003 tx+=tstep;
26854 45003 break;
26855 }
26856 }
26857 }
26858
26859 189526 s+=tstep;
26860 189526 }
26861
26862 11094 z3step=2;
26863
26864 11094 x = x.getInt();
26865 11094 y = y.getInt();
26866
2/2
✓ Branch 0 taken 200387 times.
✓ Branch 1 taken 11091 times.
211478 while(s>=0)
26867 {
26868
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 199886 times.
200387 if(diagonalMovement)
26869 {
26870
5/6
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 445 times.
✓ Branch 4 taken 56 times.
✗ Branch 5 not taken.
501 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
26871 {
26872 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
26873 {
26874 walkable = false;
26875 shiftdir = -1;
26876 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
26877 switch(tdir)
26878 {
26879 case left:
26880 --x;
26881 break;
26882 case right:
26883 ++x;
26884 break;
26885 case up:
26886 --y;
26887 break;
26888 case down:
26889 ++y;
26890 break;
26891 }
26892 }
26893 else
26894 {
26895 walkable=false;
26896 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
26897 moveOld2(dir, 150);
26898 }
26899 }
26900 else
26901 {
26902
3/4
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 244 times.
501 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
26903 {
26904 257 s-=1.5;
26905 257 }
26906 else
26907 {
26908 244 s-=z3step;
26909 }
26910 501 walkable=true;
26911 501 moveOld2(dir, 150);
26912 }
26913
26914 501 shiftdir=-1;
26915 501 }
26916 else
26917 {
26918
3/6
✓ Branch 0 taken 111675 times.
✓ Branch 1 taken 88211 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 199886 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
199886 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
26919 {
26920 walkable=false;
26921 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
26922 switch(tdir)
26923 {
26924 case left:
26925 --x;
26926 break;
26927 case right:
26928 ++x;
26929 break;
26930 case up:
26931 --y;
26932 break;
26933 case down:
26934 ++y;
26935 break;
26936 }
26937 }
26938 else
26939 {
26940
2/4
✓ Branch 0 taken 199886 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 199886 times.
199886 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
26941 {
26942 s-=1.5;
26943 }
26944
2/2
✓ Branch 0 taken 111675 times.
✓ Branch 1 taken 88211 times.
199886 else if(dir<left)
26945 {
26946 111675 s-=lsteps[y.getInt()&7];
26947 111675 }
26948 else
26949 {
26950 88211 s-=lsteps[x.getInt()&7];
26951 }
26952
26953 199886 moveOld2(dir, 150);
26954 }
26955 }
26956
26957
2/2
✓ Branch 0 taken 189296 times.
✓ Branch 1 taken 11091 times.
200387 if(s<0)
26958 {
26959 // Not quite sure how this is actually supposed to work.
26960 // There have to be two cases for each direction or Hero
26961 // either walks too far onto the screen or may get stuck
26962 // going through walk-through walls.
26963
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4001 times.
✓ Branch 2 taken 2454 times.
✓ Branch 3 taken 2115 times.
✓ Branch 4 taken 2521 times.
11091 switch(dir)
26964 {
26965 case up:
26966
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 3776 times.
4001 if(y<8) // Leaving the screen
26967 225 y+=s;
26968 else // Entering the screen
26969 3776 y-=s;
26970
26971 4001 break;
26972
26973 case down:
26974
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 2238 times.
2454 if(y>152)
26975 216 y-=s;
26976 else
26977 2238 y+=s;
26978
26979 2454 break;
26980
26981 case left:
26982
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 1940 times.
2115 if(x<8)
26983 175 x+=s;
26984 else
26985 1940 x-=s;
26986
26987 2115 break;
26988
26989 case right:
26990
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 2326 times.
2521 if(x>=232)
26991 195 x-=s;
26992 else
26993 2326 x+=s;
26994
26995 2521 break;
26996 }
26997 11091 }
26998
26999
27000 200387 clear_darkroom_bitmaps();
27001 200387 draw_screen(tmpscr);
27002
1/2
✓ Branch 0 taken 200387 times.
✗ Branch 1 not taken.
200387 if (canSideviewLadder()) setOnSideviewLadder(true);
27003 200387 advanceframe(true);
27004
27005
2/2
✓ Branch 0 taken 200384 times.
✓ Branch 1 taken 3 times.
200387 if(Quit)
27006 3 return;
27007 }
27008
4/4
✓ Branch 0 taken 8570 times.
✓ Branch 1 taken 2521 times.
✓ Branch 2 taken 2454 times.
✓ Branch 3 taken 6116 times.
11091 if(dir==right||dir==down)
27009 {
27010 4975 x=int32_t(x);
27011 4975 y=int32_t(y);
27012 4975 }
27013 else
27014 {
27015 6116 x = x.getInt();
27016 6116 y = y.getInt();
27017 }
27018 11091 set_respawn_point();
27019 11091 draw_screen(tmpscr);
27020 11091 eat_buttons();
27021 11091 shiftdir=sh;
27022 11094 }
27023
27024 456 void HeroClass::walkdown(bool opening) //entering cave
27025 {
27026
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 398 times.
456 if(opening)
27027 {
27028 398 close_black_opening(x+8, y+8+playing_field_offset, false);
27029 398 }
27030
27031 456 hclk=0;
27032 456 stop_item_sfx(itype_brang);
27033 456 sfx(WAV_STAIRS,pan(x.getInt()));
27034 456 clk=0;
27035 // int32_t cmby=(y.getInt()&0xF0)+16;
27036 // Fix Hero's position to the grid
27037 456 y=y.getInt()&0xF0;
27038 456 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
27039 456 attack=wNone;
27040 456 attackid=-1;
27041 456 reset_swordcharge();
27042 456 climb_cover_x=x.getInt()&0xF0;
27043 456 climb_cover_y=(y.getInt()&0xF0)+16;
27044
27045 456 guys.clear();
27046 456 chainlinks.clear();
27047 456 Lwpns.clear();
27048 456 Ewpns.clear();
27049 456 items.clear();
27050
2/2
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 29184 times.
29640 for(int32_t i=0; i<64; i++)
27051 {
27052 29184 herostep();
27053
27054
2/4
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27055 hero_count=(hero_count+1)%16;
27056
27057
2/2
✓ Branch 0 taken 21888 times.
✓ Branch 1 taken 7296 times.
29184 if((i&3)==3)
27058 7296 ++y;
27059
27060 29184 draw_screen(tmpscr);
27061 29184 advanceframe(true);
27062
27063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(Quit)
27064 break;
27065 29184 }
27066
27067 456 action=none; FFCore.setHeroAction(none);
27068 456 }
27069
27070 120 void HeroClass::walkdown2(bool opening) //exiting cave 2
27071 {
27072 120 int32_t type = combobuf[MAPCOMBO(x,y)].type;
27073
27074
27075 // Fix Hero's position to the grid
27076 120 y=y.getInt()&0xF0;
27077
27078
3/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
27079 99 y -= 16;
27080
27081 120 climb_cover_x=x.getInt()&0xF0;
27082 120 climb_cover_y=y.getInt()&0xF0;
27083
27084 120 dir=down;
27085 120 z=fakez=fall=fakefall=0;
27086
27087
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 25 times.
120 if(opening)
27088 {
27089 25 open_black_opening(x+8, y+8+playing_field_offset+16, false);
27090 25 }
27091
27092 120 hclk=0;
27093 120 stop_item_sfx(itype_brang);
27094 120 sfx(WAV_STAIRS,pan(x.getInt()));
27095 120 clk=0;
27096 120 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
27097 120 attack=wNone;
27098 120 attackid=-1;
27099 120 reset_swordcharge();
27100
27101 120 guys.clear();
27102 120 chainlinks.clear();
27103 120 Lwpns.clear();
27104 120 Ewpns.clear();
27105 120 items.clear();
27106
27107
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 7680 times.
7800 for(int32_t i=0; i<64; i++)
27108 {
27109 7680 herostep();
27110
27111
2/4
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7680 times.
7680 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27112 hero_count=(hero_count+1)%16;
27113
27114
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 1920 times.
7680 if((i&3)==3)
27115 1920 ++y;
27116
27117 7680 draw_screen(tmpscr);
27118 7680 advanceframe(true);
27119
27120
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(Quit)
27121 break;
27122 7680 }
27123
27124
27125 120 action=none; FFCore.setHeroAction(none);
27126 120 }
27127
27128 379 void HeroClass::walkup(bool opening) //exiting cave
27129 {
27130 379 int32_t type = combobuf[MAPCOMBO(x,y)].type;
27131
27132
5/6
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 298 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
379 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
27133 55 y+=16;
27134
27135 // Fix Hero's position to the grid
27136 379 y=y.getInt()&0xF0;
27137 379 z=fakez=fall=fakefall=0;
27138
27139
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 331 times.
379 if(opening)
27140 {
27141 331 open_black_opening(x+8, y+8+playing_field_offset-16, false);
27142 331 }
27143
27144 379 hclk=0;
27145 379 stop_item_sfx(itype_brang);
27146 379 sfx(WAV_STAIRS,pan(x.getInt()));
27147 379 dir=down;
27148 379 clk=0;
27149 // int32_t cmby=y.getInt()&0xF0;
27150 379 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
27151 379 attack=wNone;
27152 379 attackid=-1;
27153 379 reset_swordcharge();
27154 379 climb_cover_x=x.getInt()&0xF0;
27155 379 climb_cover_y=y.getInt()&0xF0;
27156
27157 379 guys.clear();
27158 379 chainlinks.clear();
27159 379 Lwpns.clear();
27160 379 Ewpns.clear();
27161 379 items.clear();
27162
27163
2/2
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 24256 times.
24635 for(int32_t i=0; i<64; i++)
27164 {
27165 24256 herostep();
27166
27167
2/4
✓ Branch 0 taken 24256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24256 times.
24256 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27168 hero_count=(hero_count+1)%16;
27169
27170
2/2
✓ Branch 0 taken 18192 times.
✓ Branch 1 taken 6064 times.
24256 if((i&3)==0)
27171 6064 --y;
27172
27173 24256 draw_screen(tmpscr);
27174 24256 advanceframe(true);
27175
27176
1/2
✓ Branch 0 taken 24256 times.
✗ Branch 1 not taken.
24256 if(Quit)
27177 break;
27178 24256 }
27179 379 map_bkgsfx(true);
27180 379 loadside=dir^1;
27181 379 action=none; FFCore.setHeroAction(none);
27182 379 }
27183
27184 421 void HeroClass::walkup2(bool opening) //entering cave2
27185 {
27186
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 325 times.
421 if(opening)
27187 {
27188 325 close_black_opening(x+8, y+8+playing_field_offset, false);
27189 325 }
27190
27191 421 hclk=0;
27192 421 stop_item_sfx(itype_brang);
27193 421 sfx(WAV_STAIRS,pan(x.getInt()));
27194 421 dir=up;
27195 421 clk=0;
27196 // int32_t cmby=y.getInt()&0xF0;
27197 421 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
27198 421 attack=wNone;
27199 421 attackid=-1;
27200 421 reset_swordcharge();
27201 421 climb_cover_x=x.getInt()&0xF0;
27202 421 climb_cover_y=(y.getInt()&0xF0)-16;
27203
27204 421 guys.clear();
27205 421 chainlinks.clear();
27206 421 Lwpns.clear();
27207 421 Ewpns.clear();
27208 421 items.clear();
27209
27210
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 26944 times.
27365 for(int32_t i=0; i<64; i++)
27211 {
27212 26944 herostep();
27213
27214
2/4
✓ Branch 0 taken 26944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26944 times.
26944 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27215 hero_count=(hero_count+1)%16;
27216
27217
2/2
✓ Branch 0 taken 20208 times.
✓ Branch 1 taken 6736 times.
26944 if((i&3)==0)
27218 6736 --y;
27219
27220 26944 draw_screen(tmpscr);
27221 26944 advanceframe(true);
27222
27223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26944 times.
26944 if(Quit)
27224 break;
27225 26944 }
27226 421 map_bkgsfx(true);
27227 421 loadside=dir^1;
27228 421 action=none; FFCore.setHeroAction(none);
27229 421 }
27230
27231 455 void HeroClass::stepout() // Step out of item cellars and passageways
27232 {
27233 455 bool updatemusic = FFCore.can_dmap_change_music(currdmap);
27234 455 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
27235
27236 455 int32_t sc = specialcave; // This gets erased by ALLOFF()
27237 455 ALLOFF();
27238 455 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27239 455 map_bkgsfx(false);
27240 455 kill_enemy_sfx();
27241 455 draw_screen(tmpscr,false);
27242 455 fade(sc>=GUYCAVE?10:11,true,false);
27243 455 blackscr(30,true);
27244 455 ringcolor(false);
27245
27246
4/4
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 271 times.
455 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
27247 {
27248 271 currdmap=stepoutdmap;
27249 271 currmap=DMaps[currdmap].map;
27250 271 dlevel=DMaps[currdmap].level;
27251
27252 //we might have just left a passage, so be sure to update the CSet record -DD
27253 271 currcset=DMaps[currdmap].color;
27254
27255 271 init_dmap();
27256 271 homescr=stepoutscr;
27257 271 }
27258
27259 455 currscr=homescr;
27260 455 loadscr(0,currdmap,currscr,255,false); // bogus direction
27261 455 draw_screen(tmpscr,false);
27262
27263
4/4
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 444 times.
✓ Branch 3 taken 10 times.
455 if(get_qr(qr_NEW_DARKROOM) || !(tmpscr->flags&fDARK))
27264 {
27265 445 darkroom = naturaldark = false;
27266 445 fade(DMaps[currdmap].color,true,true);
27267 445 }
27268 else
27269 {
27270 10 darkroom = naturaldark = true;
27271
27272
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if(get_qr(qr_FADE))
27273 {
27274 8 interpolatedfade();
27275 8 }
27276 else
27277 {
27278 2 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
27279 }
27280 10 byte *si = colordata + CSET(DMaps[currdmap].color*pdLEVEL+poLEVEL)*3;
27281 10 si+=3*48;
27282
27283
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 10 times.
170 for(int32_t i=0; i<16; i++)
27284 {
27285 160 RAMpal[CSET(9)+i] = _RGB(si);
27286 160 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
27287 160 si+=3;
27288 160 }
27289 }
27290
27291 455 x = tmpscr->warpreturnx[stepoutwr];
27292 455 y = tmpscr->warpreturny[stepoutwr];
27293
27294
1/2
✓ Branch 0 taken 455 times.
✗ Branch 1 not taken.
455 if(didpit)
27295 {
27296 didpit=false;
27297 x=pitx;
27298 y=pity;
27299 }
27300
27301
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 20 times.
455 if(x+y == 0)
27302 20 x = y = 80;
27303
27304 455 dir=down;
27305
27306 455 set_respawn_point();
27307
27308 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
27309 455 int32_t type = combobuf[MAPCOMBO(tmpscr->warpreturnx[stepoutwr],tmpscr->warpreturny[stepoutwr])].type;
27310
27311
4/6
✓ Branch 0 taken 455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 449 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
455 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
27312 {
27313 walkup(false);
27314 }
27315
4/6
✓ Branch 0 taken 455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 449 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
455 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
27316 {
27317 walkdown2(false);
27318 }
27319
27320 455 newscr_clk=frame;
27321 455 activated_timed_warp=false;
27322 455 didstuff=0;
27323 455 usecounts.clear();
27324 455 eat_buttons();
27325 455 markBmap(-1);
27326 455 map_bkgsfx(true);
27327
27328
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 54 times.
455 if(!get_qr(qr_CAVEEXITNOSTOPMUSIC))
27329 {
27330
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if (updatemusic || !musicnocut)
27331 {
27332 54 music_stop();
27333 54 playLevelMusic();
27334 54 }
27335 54 }
27336
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 else if(get_qr(qr_SCREEN80_OWN_MUSIC))
27337 {
27338 if (updatemusic || !musicnocut)
27339 playLevelMusic();
27340 }
27341
27342 455 loadside=dir^1;
27343 455 }
27344
27345 30834 bool HeroClass::nextcombo_wf(int32_t d2)
27346 {
27347
6/8
✓ Branch 0 taken 30774 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 30335 times.
✓ Branch 3 taken 439 times.
✓ Branch 4 taken 30335 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 439 times.
✗ Branch 7 not taken.
30834 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
27348 30834 return false;
27349
27350 // assumes Hero is about to scroll screens
27351 int ns;
27352 if(auto scr = nextscr(d2,false))
27353 ns = *scr;
27354 else return false;
27355
27356 int32_t cx = x;
27357 int32_t cy = y;
27358
27359 switch(d2)
27360 {
27361 case up:
27362 cy=160;
27363 break;
27364
27365 case down:
27366 cy=0;
27367 break;
27368
27369 case left:
27370 cx=240;
27371 break;
27372
27373 case right:
27374 cx=0;
27375 break;
27376 }
27377
27378 // check lower half of combo
27379 cy += 8;
27380
27381 // from MAPCOMBO()
27382 int32_t cmb = (cy&0xF0)+(cx>>4);
27383
27384 if(cmb>175)
27385 return true;
27386
27387 const newcombo* c = &combobuf[TheMaps[ns].data[cmb]];
27388 bool dried = iswater_type(c->type) && DRIEDLAKE;
27389 bool swim = iswater_type(c->type) && (current_item(itype_flippers)) && !dried;
27390 int32_t b=1;
27391
27392 if(cx&8) b<<=2;
27393
27394 if(cy&8) b<<=1;
27395
27396 if((c->walk&b) && !dried && !swim)
27397 return true;
27398
27399 // next block (i.e. cnt==2)
27400 if(!(cx&8))
27401 {
27402 b<<=2;
27403 }
27404 else
27405 {
27406 c = &combobuf[TheMaps[ns].data[++cmb]];
27407 dried = iswater_type(c->type) && DRIEDLAKE;
27408 swim = iswater_type(c->type) && (current_item(itype_flippers)) && !dried;
27409 b=1;
27410
27411 if(cy&8)
27412 {
27413 b<<=1;
27414 }
27415 }
27416
27417 return (c->walk&b) ? !dried && !swim : false;
27418 30834 }
27419
27420 bool HeroClass::nextcombo_solid(int32_t d2)
27421 {
27422 if(toogam || currscr>=128)
27423 return false;
27424
27425 // assumes Hero is about to scroll screens
27426 int ns;
27427 if(auto scr = nextscr(d2,false))
27428 ns = *scr;
27429 else return false;
27430
27431 int32_t screen = (ns%MAPSCRS);
27432 int32_t map = (ns - screen) / MAPSCRS;
27433
27434 int32_t cx = x;
27435 int32_t cy = y;
27436
27437 switch(d2)
27438 {
27439 case up:
27440 cy=160;
27441 break;
27442
27443 case down:
27444 cy=0;
27445 break;
27446
27447 case left:
27448 cx=240;
27449 break;
27450
27451 case right:
27452 cx=0;
27453 break;
27454 }
27455
27456 if(d2==up) cy += 8;
27457
27458 if(d2==left||d2==right) cy+=bigHitbox?0:8;
27459
27460 int32_t initcx = cx;
27461 int32_t initcy = cy;
27462 // from MAPCOMBO()
27463
27464 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
27465 {
27466 cx = initcx;
27467 for(int32_t k=0; k<=(get_qr(qr_SMARTER_SMART_SCROLL)?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
27468 {
27469 int32_t cmb = (cy&0xF0)+(cx>>4);
27470
27471 if(cmb>175)
27472 {
27473 return true;
27474 }
27475
27476 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, get_qr(qr_SMARTER_SMART_SCROLL))];
27477
27478 int32_t b=1;
27479
27480 if(cx&8) b<<=2;
27481
27482 if(cy&8) b<<=1;
27483
27484 //bool bridgedetected = false;
27485
27486 int32_t walk = c.walk;
27487 if (get_qr(qr_SMARTER_SMART_SCROLL))
27488 {
27489 for (int32_t m = 0; m <= 1; m++)
27490 {
27491 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
27492 if (cmb.type == cBRIDGE)
27493 {
27494 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
27495 {
27496 int efflag = (cmb.walk & 0xF0)>>4;
27497 int newsolid = (cmb.walk & 0xF);
27498 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
27499 }
27500 else walk &= cmb.walk;
27501 }
27502 else walk |= cmb.walk;
27503 }
27504 }
27505 /*
27506 if (bridgedetected)
27507 {
27508 continue;
27509 }*/
27510
27511 //bool swim = iswater_type(c.type) && (current_item(itype_flippers) || action==rafting);
27512 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, get_qr(qr_SMARTER_SMART_SCROLL)), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
27513
27514 if((walk&b) && !swim)
27515 {
27516 return true;
27517 }
27518 }
27519
27520 /*
27521 #if 0
27522
27523 //
27524 // next block (i.e. cnt==2)
27525 if(!(cx&8))
27526 {
27527 b<<=2;
27528 }
27529 else
27530 {
27531 c = combobuf[TheMaps[ns].data[++cmb]];
27532 dried = iswater_type(c.type) && DRIEDLAKE;
27533 //swim = iswater_type(c.type) && (current_item(itype_flippers));
27534 b=1;
27535
27536 if(cy&8)
27537 {
27538 b<<=1;
27539 }
27540 }
27541
27542 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
27543
27544 if((c.walk&b) && !dried && !swim)
27545 {
27546 return true;
27547 }
27548
27549 cx+=8;
27550
27551 if(cx&7)
27552 {
27553 if(!(cx&8))
27554 {
27555 b<<=2;
27556 }
27557 else
27558 {
27559 c = combobuf[TheMaps[ns].data[++cmb]];
27560 dried = iswater_type(c.type) && DRIEDLAKE;
27561 //swim = iswaterex(cmb, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
27562 b=1;
27563
27564 if(cy&8)
27565 {
27566 b<<=1;
27567 }
27568 }
27569
27570 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
27571
27572 if((c.walk&b) && !dried && !swim)
27573 return true;
27574 }
27575
27576 #endif
27577 */
27578 }
27579
27580 return false;
27581 }
27582
27583 14162652 void HeroClass::checkscroll()
27584 {
27585 //DO NOT scroll if Hero is vibrating due to Divine Escape effect -DD
27586
3/4
✓ Branch 0 taken 14158754 times.
✓ Branch 1 taken 3898 times.
✓ Branch 2 taken 14158754 times.
✗ Branch 3 not taken.
14162652 if(action == casting||action==sideswimcasting)
27587 3898 return;
27588
27589
2/2
✓ Branch 0 taken 8718 times.
✓ Branch 1 taken 14150036 times.
14158754 if(y<0)
27590 {
27591 8718 bool doit=true;
27592 8718 y=0;
27593
27594
5/6
✓ Branch 0 taken 8659 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 8659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8663 times.
✓ Branch 5 taken 55 times.
8718 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
27595 55 doit = false;
27596
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8706 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
8718 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
27597 doit = false;
27598
27599
1/2
✓ Branch 0 taken 8718 times.
✗ Branch 1 not taken.
8718 if(nextcombo_wf(up))
27600 doit=false;
27601
27602
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 8718 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8718 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(tmpscr->flags2&wfUP))
27603 {
27604 if(nextcombo_solid(up))
27605 doit=false;
27606 }
27607
27608
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 8663 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
8718 if(doit || action==inwind)
27609 {
27610
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 8209 times.
8663 if(currscr>=128)
27611 {
27612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(specialcave >= GUYCAVE)
27613 exitcave();
27614 454 else stepout();
27615 454 }
27616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8209 times.
8209 else if(action==inwind)
27617 {
27618 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
27619 {
27620 action=none; FFCore.setHeroAction(none);
27621 restart_level();
27622 }
27623 else
27624 {
27625 dowarp(2,up);
27626 }
27627 }
27628
3/6
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 7833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 376 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8209 else if(tmpscr->flags2&wfUP && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
27629 {
27630 376 sdir=up;
27631 376 dowarp(1,(tmpscr->sidewarpindex)&3);
27632 376 }
27633
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 7782 times.
7833 else if(!edge_of_dmap(up))
27634 {
27635 7782 scrolling_map = currmap;
27636 7782 scrollscr(up);
27637
27638
1/2
✓ Branch 0 taken 7782 times.
✗ Branch 1 not taken.
7782 if(tmpscr->flags4&fAUTOSAVE)
27639 {
27640 save_game(true,0);
27641 }
27642
27643
2/2
✓ Branch 0 taken 7457 times.
✓ Branch 1 taken 325 times.
7782 if(tmpscr->flags6&fCONTINUEHERE)
27644 {
27645 325 lastentrance_dmap = currdmap;
27646 325 lastentrance = homescr;
27647 325 }
27648 7782 }
27649 8663 }
27650 8718 }
27651
27652
2/2
✓ Branch 0 taken 7083 times.
✓ Branch 1 taken 14151671 times.
14158754 if(y>160)
27653 {
27654 7083 bool doit=true;
27655 7083 y=160;
27656
27657
5/6
✓ Branch 0 taken 6999 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 6999 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7002 times.
✓ Branch 5 taken 81 times.
7083 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
27658 81 doit = false;
27659
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7076 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7083 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
27660 doit = false;
27661
27662
1/2
✓ Branch 0 taken 7083 times.
✗ Branch 1 not taken.
7083 if(nextcombo_wf(down))
27663 doit=false;
27664
27665
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 7083 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
7083 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfDOWN))
27666 {
27667 if(nextcombo_solid(down))
27668 doit=false;
27669 }
27670
27671
3/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 7002 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
7083 if(doit || action==inwind)
27672 {
27673
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 6656 times.
7002 if(currscr>=128)
27674 {
27675
2/2
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 1 times.
346 if(specialcave >= GUYCAVE)
27676 345 exitcave();
27677 1 else stepout();
27678 346 }
27679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
6656 else if(action==inwind)
27680 {
27681 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
27682 {
27683 action=none; FFCore.setHeroAction(none);
27684 restart_level();
27685 }
27686 else
27687 {
27688 dowarp(2,down);
27689 }
27690 }
27691
3/6
✓ Branch 0 taken 950 times.
✓ Branch 1 taken 5706 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 950 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6656 else if(tmpscr->flags2&wfDOWN && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
27692 {
27693 950 sdir=down;
27694 950 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
27695 950 }
27696
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 5668 times.
5706 else if(!edge_of_dmap(down))
27697 {
27698 5668 scrolling_map = currmap;
27699 5668 scrollscr(down);
27700
27701
1/2
✓ Branch 0 taken 5668 times.
✗ Branch 1 not taken.
5668 if(tmpscr->flags4&fAUTOSAVE)
27702 {
27703 save_game(true,0);
27704 }
27705
27706
2/2
✓ Branch 0 taken 5554 times.
✓ Branch 1 taken 114 times.
5668 if(tmpscr->flags6&fCONTINUEHERE)
27707 {
27708 114 lastentrance_dmap = currdmap;
27709 114 lastentrance = homescr;
27710 114 }
27711 5668 }
27712 7002 }
27713 7083 }
27714
27715
2/2
✓ Branch 0 taken 6643 times.
✓ Branch 1 taken 14152111 times.
14158754 if(x<0)
27716 {
27717 6643 bool doit=true;
27718 6643 x=0;
27719
27720
4/6
✓ Branch 0 taken 6640 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 6640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6643 times.
✗ Branch 5 not taken.
6643 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
27721 doit = false;
27722
3/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 6567 times.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
6643 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
27723 doit = false;
27724
27725
1/2
✓ Branch 0 taken 6643 times.
✗ Branch 1 not taken.
6643 if(nextcombo_wf(left))
27726 doit=false;
27727
27728
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6643 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6643 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfLEFT))
27729 {
27730 if(nextcombo_solid(left))
27731 doit=false;
27732 }
27733
27734
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6643 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6643 if(doit || action==inwind)
27735 {
27736
1/2
✓ Branch 0 taken 6643 times.
✗ Branch 1 not taken.
6643 if(currscr>=128)
27737 {
27738 if(specialcave >= GUYCAVE)
27739 exitcave();
27740 else stepout();
27741 }
27742
27743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6643 times.
6643 if(action==inwind)
27744 {
27745 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
27746 {
27747 action=none; FFCore.setHeroAction(none);
27748 restart_level();
27749 }
27750 else
27751 {
27752 dowarp(2,left);
27753 }
27754 }
27755
3/6
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 6375 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 268 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6643 else if(tmpscr->flags2&wfLEFT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
27756 {
27757 268 sdir=left;
27758 268 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
27759 268 }
27760
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 6216 times.
6375 else if(!edge_of_dmap(left))
27761 {
27762 6216 scrolling_map = currmap;
27763 6216 scrollscr(left);
27764
27765
1/2
✓ Branch 0 taken 6216 times.
✗ Branch 1 not taken.
6216 if(tmpscr->flags4&fAUTOSAVE)
27766 {
27767 save_game(true,0);
27768 }
27769
27770
2/2
✓ Branch 0 taken 6178 times.
✓ Branch 1 taken 38 times.
6216 if(tmpscr->flags6&fCONTINUEHERE)
27771 {
27772 38 lastentrance_dmap = currdmap;
27773 38 lastentrance = homescr;
27774 38 }
27775 6216 }
27776 6643 }
27777 6643 }
27778
27779
2/2
✓ Branch 0 taken 7484 times.
✓ Branch 1 taken 14151270 times.
14158754 if(x>240)
27780 {
27781 7484 bool doit=true;
27782 7484 x=240;
27783
27784
5/6
✓ Branch 0 taken 7439 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 7439 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7439 times.
✓ Branch 5 taken 45 times.
7484 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
27785 45 doit = false;
27786
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7473 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
7484 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
27787 doit = false;
27788
27789
1/2
✓ Branch 0 taken 7484 times.
✗ Branch 1 not taken.
7484 if(nextcombo_wf(right))
27790 doit=false;
27791
27792
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 7484 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
7484 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfRIGHT))
27793 {
27794 if(nextcombo_solid(right))
27795 doit=false;
27796 }
27797
27798
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 7439 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
7484 if(doit || action==inwind)
27799 {
27800
1/2
✓ Branch 0 taken 7439 times.
✗ Branch 1 not taken.
7439 if(currscr>=128)
27801 {
27802 if(specialcave >= GUYCAVE)
27803 exitcave();
27804 else stepout();
27805 }
27806
27807
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 7327 times.
7439 if(action==inwind)
27808 {
27809
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 111 times.
112 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
27810 {
27811 1 action=none; FFCore.setHeroAction(none);
27812 1 restart_level();
27813 1 }
27814 else
27815 {
27816 111 dowarp(2,right);
27817 }
27818 112 }
27819
3/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 7040 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 287 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7327 else if(tmpscr->flags2&wfRIGHT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
27820 {
27821 287 sdir=right;
27822 287 dowarp(1,(tmpscr->sidewarpindex>>6)&3);
27823 287 }
27824
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 6928 times.
7040 else if(!edge_of_dmap(right))
27825 {
27826 6928 scrolling_map = currmap;
27827 6928 scrollscr(right);
27828
27829
1/2
✓ Branch 0 taken 6928 times.
✗ Branch 1 not taken.
6928 if(tmpscr->flags4&fAUTOSAVE)
27830 {
27831 save_game(true,0);
27832 }
27833
27834
2/2
✓ Branch 0 taken 6876 times.
✓ Branch 1 taken 52 times.
6928 if(tmpscr->flags6&fCONTINUEHERE)
27835 {
27836 52 lastentrance_dmap = currdmap;
27837 52 lastentrance = homescr;
27838 52 }
27839 6928 }
27840 7439 }
27841 7484 }
27842 14162652 }
27843
27844 // assumes current direction is in lastdir[3]
27845 // compares directions with scr->path and scr->exitdir
27846 79983 bool HeroClass::checkmaze(mapscr *scr, bool sound)
27847 {
27848
2/2
✓ Branch 0 taken 79485 times.
✓ Branch 1 taken 498 times.
79983 if(!(scr->flags&fMAZE))
27849 79485 return true;
27850
27851
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 444 times.
498 if(lastdir[3]==scr->exitdir)
27852 54 return true;
27853
27854
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 66 times.
764 for(int32_t i=0; i<4; i++)
27855
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 378 times.
698 if(lastdir[i]!=scr->path[i])
27856 378 return false;
27857
27858
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
66 if(sound)
27859 33 sfx(scr->secretsfx);
27860
27861 66 return true;
27862 79983 }
27863
27864 53389 bool HeroClass::edge_of_dmap(int32_t side)
27865 {
27866
2/2
✓ Branch 0 taken 53170 times.
✓ Branch 1 taken 219 times.
53389 if(checkmaze(tmpscr,false)==false)
27867 219 return false;
27868
27869 // needs fixin'
27870 // should check dmap style
27871
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 15480 times.
✓ Branch 2 taken 11316 times.
✓ Branch 3 taken 12499 times.
✓ Branch 4 taken 13875 times.
53170 switch(side)
27872 {
27873 case up:
27874 15480 return currscr<16;
27875
27876 case down:
27877 11316 return currscr>=112;
27878
27879 case left:
27880
2/2
✓ Branch 0 taken 12341 times.
✓ Branch 1 taken 158 times.
12499 if((currscr&15)==0)
27881 158 return true;
27882
27883
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 5236 times.
12341 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
27884 // if(dlevel)
27885 7105 return (((currscr&15)-DMaps[currdmap].xoff)<=0);
27886
27887 5236 break;
27888
27889 case right:
27890
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 13763 times.
13875 if((currscr&15)==15)
27891 112 return true;
27892
27893
2/2
✓ Branch 0 taken 7813 times.
✓ Branch 1 taken 5950 times.
13763 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
27894 // if(dlevel)
27895 7813 return (((currscr&15)-DMaps[currdmap].xoff)>=7);
27896
27897 5950 break;
27898 }
27899
27900 11186 return false;
27901 53389 }
27902
27903 454 bool HeroClass::lookaheadraftflag(int32_t d2)
27904 {
27905 // Helper for scrollscr that gets next combo on next screen.
27906 // Can use destscr for scrolling warps,
27907 // but assumes currmap is correct.
27908
27909 454 int32_t cx = x;
27910 454 int32_t cy = y + 8;
27911
27912 454 bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27913 454 bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27914 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
27915 //Applying this here, too. -Z
27916
27917
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 100 times.
✓ Branch 4 taken 115 times.
454 switch(d2)
27918 {
27919 case up:
27920 128 cy=160;
27921 128 break;
27922
27923 case down:
27924 111 cy=0;
27925 111 break;
27926
27927 case left:
27928 100 cx=240;
27929 100 break;
27930
27931 case right:
27932 115 cx=0;
27933 115 break;
27934 }
27935
27936 454 int32_t combo = (cy&0xF0)+(cx>>4);
27937
27938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 if(combo>175)
27939 return 0;
27940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 return ( isRaftFlag(combobuf[tmpscr[0].data[combo]].flag) || isRaftFlag(tmpscr[0].sflag[combo]));
27941
27942 454 }
27943 27556 int32_t HeroClass::lookahead(int32_t d2) // Helper for scrollscr that gets next combo on next screen.
27944 {
27945 // Can use destscr for scrolling warps,
27946 // but assumes currmap is correct.
27947
27948 27556 int32_t cx = vbound(x,0_zf,240_zf); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
27949 27556 int32_t cy = vbound(y + 8,0_zf,160_zf);
27950 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27951 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27952 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
27953
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8007 times.
✓ Branch 2 taken 5875 times.
✓ Branch 3 taken 6418 times.
✓ Branch 4 taken 7256 times.
27556 switch(d2)
27954 {
27955 case up:
27956 8007 cy=160;
27957 8007 break;
27958
27959 case down:
27960 5875 cy=0;
27961 5875 break;
27962
27963 case left:
27964 6418 cx=240;
27965 6418 break;
27966
27967 case right:
27968 7256 cx=0;
27969 7256 break;
27970 }
27971
27972 27556 int32_t combo = (cy&0xF0)+(cx>>4);
27973
27974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27556 times.
27556 if(combo>175)
27975 return 0;
27976
27977 27556 return tmpscr[0].data[combo]; // entire combo code
27978 27556 }
27979
27980 27556 int32_t HeroClass::lookaheadflag(int32_t d2)
27981 {
27982 // Helper for scrollscr that gets next combo on next screen.
27983 // Can use destscr for scrolling warps,
27984 // but assumes currmap is correct.
27985
27986 27556 int32_t cx = vbound(x,0_zf,240_zf);
27987 27556 int32_t cy = vbound(y + 8,0_zf,160_zf);
27988
27989 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27990 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27991 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
27992 //Applying this here, too. -Z
27993
27994
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8007 times.
✓ Branch 2 taken 5875 times.
✓ Branch 3 taken 6418 times.
✓ Branch 4 taken 7256 times.
27556 switch(d2)
27995 {
27996 case up:
27997 8007 cy=160;
27998 8007 break;
27999
28000 case down:
28001 5875 cy=0;
28002 5875 break;
28003
28004 case left:
28005 6418 cx=240;
28006 6418 break;
28007
28008 case right:
28009 7256 cx=0;
28010 7256 break;
28011 }
28012
28013 27556 int32_t combo = (cy&0xF0)+(cx>>4);
28014
28015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27556 times.
27556 if(combo>175)
28016 return 0;
28017
28018
2/2
✓ Branch 0 taken 26693 times.
✓ Branch 1 taken 863 times.
27556 if(!tmpscr[0].sflag[combo])
28019 {
28020 26693 return combobuf[tmpscr[0].data[combo]].flag; // flag
28021 }
28022
28023 863 return tmpscr[0].sflag[combo]; // flag
28024 27556 }
28025
28026 3215822 void HeroClass::run_scrolling_script_int(bool waitdraw)
28027 {
28028
2/2
✓ Branch 0 taken 1607073 times.
✓ Branch 1 taken 1608749 times.
3215822 if(waitdraw)
28029 {
28030
3/4
✓ Branch 0 taken 1607073 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1129714 times.
✓ Branch 3 taken 477359 times.
1607073 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
28031 {
28032 477359 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
28033 477359 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
28034 477359 }
28035 1607073 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
28036
5/6
✓ Branch 0 taken 1606416 times.
✓ Branch 1 taken 657 times.
✓ Branch 2 taken 35905 times.
✓ Branch 3 taken 1570511 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35905 times.
1607073 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28037 {
28038 35905 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
28039 35905 FFCore.waitdraw(ScriptType::Player) = false;
28040 35905 }
28041 1607073 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
28042
4/6
✓ Branch 0 taken 1607073 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1989 times.
✓ Branch 3 taken 1605084 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1989 times.
1607073 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28043 {
28044 1989 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
28045 1989 FFCore.waitdraw(ScriptType::DMap) = false;
28046 1989 }
28047 1607073 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
28048
2/6
✓ Branch 0 taken 1607073 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1607073 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1607073 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28049 {
28050 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
28051 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
28052 }
28053 1607073 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
28054
5/10
✓ Branch 0 taken 1606483 times.
✓ Branch 1 taken 590 times.
✓ Branch 2 taken 2161 times.
✓ Branch 3 taken 1604322 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2161 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1607073 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && FFCore.waitdraw(ScriptType::Screen, currscr) && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28055 {
28056 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script, currscr);
28057 FFCore.waitdraw(ScriptType::Screen, currscr) = 0;
28058 }
28059 1607073 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
28060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1607073 times.
1607073 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
28061 {
28062 1607073 FFCore.itemScriptEngineOnWaitdraw();
28063 1607073 }
28064 1607073 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
28065 1607073 }
28066 else
28067 {
28068
7/8
✓ Branch 0 taken 1608159 times.
✓ Branch 1 taken 590 times.
✓ Branch 2 taken 2200 times.
✓ Branch 3 taken 1605959 times.
✓ Branch 4 taken 987 times.
✓ Branch 5 taken 1213 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 987 times.
1608749 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28069 {
28070 987 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script, currscr);
28071 987 }
28072 1608749 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
28073
3/4
✓ Branch 0 taken 1608749 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 529689 times.
✓ Branch 3 taken 1079060 times.
1608749 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.doscript(ScriptType::Global, GLOBAL_SCRIPT_GAME))
28074 {
28075 529689 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
28076 529689 }
28077 1608749 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
28078
6/6
✓ Branch 0 taken 1608091 times.
✓ Branch 1 taken 658 times.
✓ Branch 2 taken 1545267 times.
✓ Branch 3 taken 62824 times.
✓ Branch 4 taken 1508889 times.
✓ Branch 5 taken 36378 times.
1608749 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.doscript(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
28079 {
28080 36378 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
28081 36378 }
28082 1608749 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
28083
5/6
✓ Branch 0 taken 1608749 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1607893 times.
✓ Branch 3 taken 856 times.
✓ Branch 4 taken 1508889 times.
✓ Branch 5 taken 99004 times.
1608749 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28084 {
28085 99004 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
28086 99004 }
28087 1608749 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
28088
4/6
✓ Branch 0 taken 1608749 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1608749 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1508889 times.
✓ Branch 5 taken 99860 times.
1608749 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28089 {
28090 99860 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
28091 99860 }
28092 1608749 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
28093 1608749 bool old = get_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING);
28094
3/4
✓ Branch 0 taken 1608749 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56094 times.
✓ Branch 3 taken 1552655 times.
1608749 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
28095 1552655 FFCore.itemScriptEngine();
28096 1608749 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
28097
3/4
✓ Branch 0 taken 1608749 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1552655 times.
✓ Branch 3 taken 56094 times.
1608749 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
28098 56094 FFCore.itemScriptEngine();
28099 }
28100 3215822 }
28101 //Bit of a messy kludge to give the correct Hero->X/Hero->Y in the script
28102 3215822 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
28103 {
28104 // For rafting (and possibly other esoteric things)
28105 // Hero's action should remain unchanged while scrolling,
28106 // but for the sake of scripts, here's an eye-watering kludge.
28107 3215822 actiontype lastaction = action;
28108 3215822 action=scrolling; FFCore.setHeroAction(scrolling);
28109
2/2
✓ Branch 0 taken 1607073 times.
✓ Branch 1 taken 1608749 times.
3215822 if(waitdraw)
28110 {
28111 1607073 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
28112 1607073 }
28113 else
28114 {
28115 1608749 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
28116 }
28117 3215822 zfix storex = x, storey = y;
28118
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 808438 times.
✓ Branch 2 taken 581193 times.
✓ Branch 3 taken 854462 times.
✓ Branch 4 taken 971729 times.
3215822 switch(scrolldir)
28119 {
28120 case up:
28121
2/2
✓ Branch 0 taken 660493 times.
✓ Branch 1 taken 147945 times.
808438 if(y < 160) y = 176;
28122
4/4
✓ Branch 0 taken 123971 times.
✓ Branch 1 taken 23974 times.
✓ Branch 2 taken 52654 times.
✓ Branch 3 taken 71317 times.
147945 else if(cx > 0 && !end_frames) y = sy + 156;
28123 76628 else y = 160;
28124
28125 808438 break;
28126
28127 case down:
28128
2/2
✓ Branch 0 taken 473201 times.
✓ Branch 1 taken 107992 times.
581193 if(y > 0) y = -16;
28129
4/4
✓ Branch 0 taken 90181 times.
✓ Branch 1 taken 17811 times.
✓ Branch 2 taken 39760 times.
✓ Branch 3 taken 50421 times.
107992 else if(cx > 0 && !end_frames) y = sy - 172;
28130 57571 else y = 0;
28131
28132 581193 break;
28133
28134 case left:
28135
2/2
✓ Branch 0 taken 783189 times.
✓ Branch 1 taken 71273 times.
854462 if(x < 240) x = 256;
28136
2/2
✓ Branch 0 taken 58027 times.
✓ Branch 1 taken 13246 times.
71273 else if(cx > 0) x = sx + 236;
28137 13246 else x = 240;
28138
28139 854462 break;
28140
28141 case right:
28142
2/2
✓ Branch 0 taken 890890 times.
✓ Branch 1 taken 80839 times.
971729 if(x > 0) x = -16;
28143
2/2
✓ Branch 0 taken 65887 times.
✓ Branch 1 taken 14952 times.
80839 else if(cx > 0) x = sx - 252;
28144 14952 else x = 0;
28145
28146 971729 break;
28147 }
28148 3215822 run_scrolling_script_int(waitdraw);
28149
28150 3215822 x = storex, y = storey;
28151
28152 3215822 action=lastaction; FFCore.setHeroAction(lastaction);
28153 3215822 }
28154
28155 //Has solving the maze enabled a side warp?
28156 //Only used just before scrolling screens
28157 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
28158 // return true to abort the topmost scrollscr() call. -L
28159 27556 bool HeroClass::maze_enabled_sizewarp(int32_t scrolldir)
28160 {
28161
2/2
✓ Branch 0 taken 82668 times.
✓ Branch 1 taken 27556 times.
110224 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
28162
28163
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 27334 times.
27556 lastdir[3] = tmpscr->flags&fMAZE ? scrolldir : 0xFF;
28164
28165
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27556 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27556 if(tmpscr->flags8&fMAZEvSIDEWARP && tmpscr->flags&fMAZE && scrolldir != tmpscr->exitdir)
28166 {
28167 switch(scrolldir)
28168 {
28169 case up:
28170 if(tmpscr->flags2&wfUP && checkmaze(tmpscr,true))
28171 {
28172 lastdir[3] = 0xFF;
28173 sdir=up;
28174 dowarp(1,(tmpscr->sidewarpindex)&3);
28175 return true;
28176 }
28177
28178 break;
28179
28180 case down:
28181 if(tmpscr->flags2&wfDOWN && checkmaze(tmpscr,true))
28182 {
28183 lastdir[3] = 0xFF;
28184 sdir=down;
28185 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
28186 return true;
28187 }
28188
28189 break;
28190
28191 case left:
28192 if(tmpscr->flags2&wfLEFT && checkmaze(tmpscr,true))
28193 {
28194 lastdir[3] = 0xFF;
28195 sdir=left;
28196 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
28197 return true;
28198 }
28199
28200 break;
28201
28202 case right:
28203 if(tmpscr->flags2&wfRIGHT && checkmaze(tmpscr,true))
28204 {
28205 lastdir[3] = 0xFF;
28206 sdir=right;
28207 dowarp(1,(tmpscr->sidewarpindex)&3);
28208 return true;
28209 }
28210
28211 break;
28212 }
28213 }
28214
28215 27556 return false;
28216 27556 }
28217
28218 27556 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
28219 {
28220 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
28221
2/2
✓ Branch 0 taken 2578 times.
✓ Branch 1 taken 24978 times.
27556 if(get_qr(qr_VERYFASTSCROLLING))
28222 2578 return 16;
28223
28224
2/2
✓ Branch 0 taken 23522 times.
✓ Branch 1 taken 1456 times.
24978 if(get_qr(qr_SMOOTHVERTICALSCROLLING) != 0)
28225 {
28226
2/2
✓ Branch 0 taken 15535 times.
✓ Branch 1 taken 7987 times.
23522 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 2 : 4;
28227 }
28228 else
28229 {
28230
4/4
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 485 times.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 776 times.
1456 if(scrolldir == up || scrolldir == down)
28231 {
28232 680 return 8;
28233 }
28234 else
28235 {
28236
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 435 times.
776 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 2 : 4;
28237 }
28238 }
28239 27556 }
28240
28241 27556 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
28242 {
28243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27556 times.
27556 if(get_qr(qr_NOSCROLL))
28244 return 0;
28245
28246
4/4
✓ Branch 0 taken 24978 times.
✓ Branch 1 taken 2578 times.
✓ Branch 2 taken 23522 times.
✓ Branch 3 taken 1456 times.
27556 if( (get_qr(qr_VERYFASTSCROLLING) != 0) ||
28247 24978 (get_qr(qr_SMOOTHVERTICALSCROLLING) != 0) )
28248 {
28249 26100 return 1;
28250 }
28251 else
28252 {
28253
4/4
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 485 times.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 776 times.
1456 if(scrolldir == up || scrolldir == down)
28254 {
28255
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 321 times.
680 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 4 : 2;
28256 }
28257 else
28258 {
28259 776 return 1;
28260 }
28261 }
28262 27556 }
28263
28264 249483 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
28265 {
28266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249483 times.
249483 if(!get_qr(qr_NEW_DARKROOM)) return;
28267 249483 int32_t lampid = current_item_id(itype_lantern);
28268
2/2
✓ Branch 0 taken 248624 times.
✓ Branch 1 taken 859 times.
249483 if(lampid < 0) return;
28269
2/4
✓ Branch 0 taken 248624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248624 times.
✗ Branch 3 not taken.
248624 if(!(checkbunny(lampid) && checkmagiccost(lampid,lamp_paid)))
28270 {
28271 lamp_paid = false;
28272 return;
28273 }
28274 248624 lamp_paid = true;
28275 248624 paymagiccost(lampid,false,true);
28276 248624 int32_t hx1 = x.getInt() - x1 + 8;
28277 248624 int32_t hy1 = y.getInt() - y1 + 8;
28278 248624 int32_t hx2 = x.getInt() - x2 + 8;
28279 248624 int32_t hy2 = y.getInt() - y2 + 8;
28280
28281 248624 itemdata& lamp = itemsbuf[lampid];
28282 248624 handle_lighting(hx1,hy1,lamp.misc1,lamp.misc2,dir,darkscr_bmp_curscr);
28283 248624 handle_lighting(hx2,hy2,lamp.misc1,lamp.misc2,dir,darkscr_bmp_scrollscr);
28284 249483 }
28285
28286 27556 void HeroClass::scrollscr(int32_t scrolldir, int32_t destscr, int32_t destdmap)
28287 {
28288
2/4
✓ Branch 0 taken 27556 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27556 times.
27556 if(action==freeze||action==sideswimfreeze)
28289 {
28290 return;
28291 }
28292
28293 27556 bool overlay = false;
28294
28295
2/4
✓ Branch 0 taken 27556 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27556 times.
27556 if(scrolldir >= 0 && scrolldir <= 3)
28296 {
28297 27556 overlay = get_bit(&tmpscr[(currscr < 128) ? 0 : 1].sidewarpoverlayflags, scrolldir) ? true : false;
28298 27556 }
28299
28300 27556 bool updatemusic = FFCore.can_dmap_change_music(destdmap);
28301 27556 bool musicrevert = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_REVERT;
28302
28303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27556 times.
27556 if(maze_enabled_sizewarp(scrolldir)) // dowarp() was called
28304 return;
28305
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27556 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27556 bool isForceFaceUp = getOnSideviewLadder() && canSideviewLadder() &&
28306 !(jumping<0 || fall!=0 || fakefall!=0) && get_qr(qr_SIDEVIEWLADDER_FACEUP);
28307 27556 bool room_was_dark = room_is_dark;
28308
1/2
✓ Branch 0 taken 27556 times.
✗ Branch 1 not taken.
27556 if(isForceFaceUp) dir = up;
28309 27556 kill_enemy_sfx();
28310 27556 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
28311 27556 screenscrolling = true;
28312 27556 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
28313
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8007 times.
✓ Branch 2 taken 5875 times.
✓ Branch 3 taken 6418 times.
✓ Branch 4 taken 7256 times.
27556 switch(scrolldir)
28314 {
28315 case up:
28316 8007 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
28317 8007 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
28318 8007 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28319 8007 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28320 8007 break;
28321 case down:
28322 5875 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
28323 5875 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
28324 5875 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28325 5875 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28326 5875 break;
28327 case left:
28328 6418 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
28329 6418 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
28330 6418 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28331 6418 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28332 6418 break;
28333 case right:
28334 7256 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
28335 7256 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
28336 7256 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28337 7256 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28338 7256 break;
28339 }
28340 27556 FFCore.clear_combo_scripts();
28341 27556 tmpscr[1] = tmpscr[0];
28342
28343
2/2
✓ Branch 0 taken 165336 times.
✓ Branch 1 taken 27556 times.
192892 for(int32_t i = 0; i < 6; i++)
28344 {
28345 165336 tmpscr3[i] = tmpscr2[i];
28346 165336 }
28347
28348 27556 conveyclk = 2;
28349
28350 27556 mapscr *newscr = &tmpscr[0];
28351 27556 mapscr *oldscr = &tmpscr[1];
28352
28353 //scroll x, scroll y, old screen x, old screen y, new screen x, new screen y
28354 27556 int32_t sx = 0, sy = 0, tx = 0, ty = 0, tx2 = 0, ty2 = 0;
28355 27556 int32_t cx = 0;
28356 27556 int32_t step = get_scroll_step(scrolldir);
28357 27556 int32_t delay = get_scroll_delay(scrolldir);
28358 27556 bool end_frames = false;
28359
28360 27556 int32_t scx = get_qr(qr_FASTDNGN) ? 30 : 0;
28361
2/2
✓ Branch 0 taken 24978 times.
✓ Branch 1 taken 2578 times.
27556 if(get_qr(qr_VERYFASTSCROLLING)) //just a minor adjustment.
28362 2578 scx = 32; //for sideview very fast screolling.
28363
28364
28365 27556 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging; bool lasttapping = tapping;
28366 27556 actiontype lastaction = action;
28367 27556 ALLOFF(false, false);
28368 // for now, restore Hero's previous action
28369
2/2
✓ Branch 0 taken 25836 times.
✓ Branch 1 taken 1720 times.
27556 if(!get_qr(qr_SCROLLING_KILLS_CHARGE))
28370 1720 charging = lastcharging;
28371
2/2
✓ Branch 0 taken 9117 times.
✓ Branch 1 taken 18439 times.
27556 if (replay_version_check(0, 28))
28372 {
28373 // nargads_trail_crystal_crusades replay tests need this.
28374
2/2
✓ Branch 0 taken 18223 times.
✓ Branch 1 taken 216 times.
18439 if(!get_qr(qr_SCROLLING_KILLS_CHARGE)) attackclk = lastattackclk;
28375 18439 spins = lastspins; charging = lastcharging; tapping = lasttapping;
28376 18439 }
28377
28378 27556 action=lastaction; FFCore.setHeroAction(lastaction);
28379
28380 27556 lstep = (lstep + 6) % 12;
28381 27556 cx = scx;
28382 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
28383
3/4
✓ Branch 0 taken 27556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18188 times.
✓ Branch 3 taken 9368 times.
27556 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
28384 {
28385 9368 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
28386 9368 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
28387 9368 }
28388 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
28389
5/6
✓ Branch 0 taken 27545 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 883 times.
✓ Branch 3 taken 26662 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 883 times.
27556 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28390 {
28391 883 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
28392 883 FFCore.waitdraw(ScriptType::Player) = false;
28393 883 }
28394 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
28395
4/6
✓ Branch 0 taken 27556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 27520 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
27556 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28396 {
28397 36 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
28398 36 FFCore.waitdraw(ScriptType::DMap) = false;
28399 36 }
28400 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
28401
2/6
✓ Branch 0 taken 27556 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27556 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27556 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28402 {
28403 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
28404 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
28405 }
28406 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
28407
7/8
✓ Branch 0 taken 27546 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 27526 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 11 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
27556 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && FFCore.waitdraw(ScriptType::Screen, currscr) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28408 {
28409 9 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script, currscr);
28410 9 FFCore.waitdraw(ScriptType::Screen, currscr) = 0;
28411 9 }
28412 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
28413
28414 27556 word c = tmpscr->numFFC();
28415
2/2
✓ Branch 0 taken 825031 times.
✓ Branch 1 taken 27556 times.
852587 for ( word q = 0; q < c; ++q )
28416 {
28417
1/2
✓ Branch 0 taken 825031 times.
✗ Branch 1 not taken.
825031 if (FFCore.waitdraw(ScriptType::FFC, q))
28418 {
28419 if(tmpscr->ffcs[q].script != 0)
28420 {
28421 ZScriptVersion::RunScript(ScriptType::FFC, tmpscr->ffcs[q].script, q);
28422 FFCore.waitdraw(ScriptType::FFC, q) = false;
28423 }
28424 }
28425 825031 }
28426 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
28427 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
28428 //Waitdraw for item scripts.
28429 27556 FFCore.itemScriptEngineOnWaitdraw();
28430 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
28431 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
28432
28433 //Sprite scripts on Waitdraw
28434 27556 FFCore.eweaponScriptEngineOnWaitdraw();
28435 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
28436 27556 FFCore.itemSpriteScriptEngineOnWaitdraw();
28437 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
28438
28439 //This is no longer a do-while, as the first iteration is now slightly different. -Em
28440 27556 draw_screen(tmpscr,true,true);
28441
28442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27556 times.
27556 if(cx == scx)
28443 27556 rehydratelake(false);
28444
28445 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
28446 27556 advanceframe(true);
28447
28448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27556 times.
27556 if(Quit)
28449 {
28450 screenscrolling = false;
28451 return;
28452 }
28453
28454 27556 ++cx;
28455
2/2
✓ Branch 0 taken 138618 times.
✓ Branch 1 taken 27556 times.
166174 while(cx < 32)
28456 {
28457
1/2
✓ Branch 0 taken 138618 times.
✗ Branch 1 not taken.
138618 if(isForceFaceUp) dir = up;
28458
2/2
✓ Branch 0 taken 579 times.
✓ Branch 1 taken 138039 times.
138618 if(get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
28459 {
28460 579 script_drawing_commands.Clear();
28461 579 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
28462 579 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
28463 579 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
28464 579 }
28465 138039 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
28466 138618 draw_screen(tmpscr,true,true);
28467
28468
1/2
✓ Branch 0 taken 138618 times.
✗ Branch 1 not taken.
138618 if(cx == scx)
28469 rehydratelake(false);
28470
28471 138618 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
28472 138618 advanceframe(true);
28473
28474
1/2
✓ Branch 0 taken 138618 times.
✗ Branch 1 not taken.
138618 if(Quit)
28475 {
28476 screenscrolling = false;
28477 return;
28478 }
28479
28480 138618 ++cx;
28481 }
28482 27556 script_drawing_commands.Clear();
28483 27556 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
28484
28485
28486 //clear Hero's last hits
28487 //for ( int32_t q = 0; q < 4; q++ ) sethitHeroUID(q, 0);
28488
28489
3/4
✓ Branch 0 taken 12040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6835 times.
✓ Branch 3 taken 8681 times.
27556 switch(DMaps[currdmap].type&dmfTYPE)
28490 {
28491 case dmDNGN:
28492
2/2
✓ Branch 0 taken 8674 times.
✓ Branch 1 taken 7 times.
8681 if(!get_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING))
28493 {
28494 7 markBmap(scrolldir);
28495 7 }
28496 8681 break;
28497 case dmOVERW: case dmBSOVERW:
28498
2/2
✓ Branch 0 taken 11799 times.
✓ Branch 1 taken 241 times.
12040 if(get_qr(qr_NO_OVERWORLD_MAP_CHARTING))
28499 11799 break;
28500 [[fallthrough]];
28501 case dmCAVE:
28502 7076 markBmap(scrolldir);
28503 7076 break;
28504 }
28505
28506
1/2
✓ Branch 0 taken 27556 times.
✗ Branch 1 not taken.
27556 if(fixed_door)
28507 {
28508 unsetmapflag(mSECRET);
28509 fixed_door = false;
28510 }
28511 //Z_scripterrlog("Setting 'scrolling_scr' from %d to %d\n", scrolling_scr, currscr);
28512 27556 scrolling_scr = currscr;
28513
28514
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8007 times.
✓ Branch 2 taken 5875 times.
✓ Branch 3 taken 6418 times.
✓ Branch 4 taken 7256 times.
27556 switch(scrolldir)
28515 {
28516 case up:
28517 {
28518
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 7782 times.
8007 if(destscr != -1)
28519 225 currscr = destscr;
28520
3/4
✓ Branch 0 taken 7720 times.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7720 times.
7782 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
28521 7720 currscr -= 16;
28522
28523 8007 loadscr(0,destdmap,currscr,scrolldir,overlay);
28524 8007 blit(scrollbuf,scrollbuf,0,0,0,176,256,176);
28525 8007 putscr(scrollbuf,0,0,newscr);
28526 8007 putscrdoors(scrollbuf,0,0,newscr);
28527 8007 sy=176;
28528
28529
2/2
✓ Branch 0 taken 7522 times.
✓ Branch 1 taken 485 times.
8007 if(get_qr(qr_SMOOTHVERTICALSCROLLING) == 0)
28530 485 sy+=3;
28531
28532 8007 cx=176/step;
28533 8007 FFCore.clear_combo_scripts();
28534 }
28535 8007 break;
28536
28537 case down:
28538 {
28539
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 5668 times.
5875 if(destscr != -1)
28540 207 currscr = destscr;
28541
3/4
✓ Branch 0 taken 5646 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5646 times.
5668 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
28542 5646 currscr += 16;
28543
28544 5875 loadscr(0,destdmap,currscr,scrolldir,overlay);
28545 5875 putscr(scrollbuf,0,176,newscr);
28546 5875 putscrdoors(scrollbuf,0,176,newscr);
28547 5875 sy = 0;
28548
28549
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 195 times.
5875 if(get_qr(qr_SMOOTHVERTICALSCROLLING) == 0)
28550 195 sy+=3;
28551
28552 5875 cx = 176 / step;
28553 5875 FFCore.clear_combo_scripts();
28554 }
28555 5875 break;
28556
28557 case left:
28558 {
28559
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 6216 times.
6418 if(destscr!=-1)
28560 202 currscr = destscr;
28561
3/4
✓ Branch 0 taken 6183 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6183 times.
6216 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
28562 6183 --currscr;
28563
28564 6418 loadscr(0,destdmap,currscr,scrolldir,overlay);
28565 6418 blit(scrollbuf,scrollbuf,0,0,256,0,256,176);
28566 6418 putscr(scrollbuf,0,0,newscr);
28567 6418 putscrdoors(scrollbuf,0,0,newscr);
28568 6418 sx = 256;
28569 6418 cx = 256 / step;
28570 6418 FFCore.clear_combo_scripts();
28571 }
28572 6418 break;
28573
28574 case right:
28575 {
28576
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 6928 times.
7256 if(destscr != -1)
28577 328 currscr = destscr;
28578
3/4
✓ Branch 0 taken 6886 times.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6886 times.
6928 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
28579 6886 ++currscr;
28580
28581 7256 loadscr(0,destdmap,currscr,scrolldir,overlay);
28582 7256 putscr(scrollbuf,256,0,newscr);
28583 7256 putscrdoors(scrollbuf,256,0,tmpscr);
28584 7256 sx = 0;
28585 7256 cx = 256 / step;
28586 7256 FFCore.clear_combo_scripts();
28587 }
28588 7256 break;
28589 }
28590
28591 // change Hero's state if entering water
28592 27556 int32_t ahead = lookahead(scrolldir);
28593 27556 int32_t aheadflag = lookaheadflag(scrolldir);
28594 27556 int32_t lookaheadx = vbound(x+8,0_zf,240_zf); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
28595 27556 int32_t lookaheady = vbound(y + (bigHitbox?8:12),0_zf,160_zf);
28596 27556 int32_t wateraheadx1 = vbound(x+4,0_zf,240_zf);
28597 27556 int32_t wateraheadx2 = vbound(x+11,0_zf,240_zf);
28598 27556 int32_t wateraheady1 = vbound(y+9,0_zf,160_zf);
28599 27556 int32_t wateraheady2 = vbound(y+15,0_zf,160_zf);
28600 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
28601 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
28602 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
28603
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8007 times.
✓ Branch 2 taken 5875 times.
✓ Branch 3 taken 6418 times.
✓ Branch 4 taken 7256 times.
27556 switch(scrolldir)
28604 {
28605 case up:
28606 8007 lookaheady=160;
28607 8007 wateraheady1=160;
28608 8007 wateraheady2=160;
28609 8007 break;
28610
28611 case down:
28612 5875 lookaheady=0;
28613 5875 wateraheady1=0;
28614 5875 wateraheady2=0;
28615 5875 break;
28616
28617 case left:
28618 6418 lookaheadx=240;
28619 6418 wateraheadx1=240;
28620 6418 wateraheadx2=240;
28621 6418 break;
28622
28623 case right:
28624 7256 lookaheadx=0;
28625 7256 wateraheadx1=0;
28626 7256 wateraheadx2=0;
28627 7256 break;
28628 }
28629
28630 27556 bool nowinwater = false;
28631
28632
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 27445 times.
27556 if(lastaction != inwind)
28633 {
28634
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 26991 times.
27445 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
28635 {
28636
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 438 times.
454 if (lookaheadraftflag(scrolldir))
28637 {
28638 438 action=rafting; FFCore.setHeroAction(rafting);
28639 438 raftclk=0;
28640 438 }
28641 454 }
28642
6/6
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 26611 times.
✓ Branch 2 taken 373 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 348 times.
26991 else if(iswaterex(ahead, currmap, currscr, -1, wateraheadx1,wateraheady1) && iswaterex(ahead, currmap, currscr, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
28643 {
28644
9/16
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 328 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 20 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 20 times.
348 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
28645 {
28646 328 SetSwim();
28647 328 hopclk = 0xFF;
28648 328 nowinwater = true;
28649 328 }
28650 else
28651 {
28652 20 action=hopping; FFCore.setHeroAction(hopping);
28653 20 hopclk = 2;
28654 20 nowinwater = true;
28655 }
28656 348 }
28657
4/4
✓ Branch 0 taken 26597 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 26611 times.
26643 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
28658 {
28659 32 action = lastaction; FFCore.setHeroAction(lastaction);
28660 32 }
28661 else
28662 {
28663 26611 action=none; FFCore.setHeroAction(none);
28664 }
28665 27445 }
28666
28667
1/2
✓ Branch 0 taken 27556 times.
✗ Branch 1 not taken.
27556 isForceFaceUp = isForceFaceUp && canSideviewLadderRemote(lookaheadx,lookaheady);
28668
28669 // The naturaldark state can be read/set by an FFC script before
28670 // fade() or lighting() is called.
28671
2/2
✓ Branch 0 taken 2055 times.
✓ Branch 1 taken 25501 times.
27556 naturaldark = !get_qr(qr_NEW_DARKROOM) && (newscr->flags & fDARK);
28672
28673
2/2
✓ Branch 0 taken 27254 times.
✓ Branch 1 taken 302 times.
27556 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
28674
28675
2/2
✓ Branch 0 taken 27101 times.
✓ Branch 1 taken 455 times.
27556 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
28676 //Preloaded ffc scripts
28677 27556 homescr=currscr;
28678 27556 auto olddmap = currdmap;
28679
2/2
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 26594 times.
27556 auto newdmap = (destdmap >= 0) ? destdmap : currdmap;
28680
28681 27556 currdmap = newdmap;
28682 27556 ffscript_engine(true);
28683 27556 currdmap = olddmap;
28684
28685 // There are two occasions when scrolling must be darkened:
28686 // 1) When scrolling into a dark room.
28687 // 2) When scrolling between DMaps of different colours.
28688
4/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 26594 times.
✓ Branch 2 taken 461 times.
✓ Branch 3 taken 501 times.
27556 if(destdmap != -1 && DMaps[destdmap].color != currcset)
28689 {
28690
1/2
✓ Branch 0 taken 501 times.
✗ Branch 1 not taken.
501 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
28691 501 darkroom = true;
28692 501 }
28693
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 26801 times.
27055 else if(!darkroom)
28694 26801 lighting(false, false); // NES behaviour: fade to dark before scrolling
28695
28696
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 27102 times.
27556 if(action != rafting) // Is this supposed to be here?!
28697
28698 27102 cx++; //This was the easiest way to re-arrange the loop so drawing is in the middle
28699
28700 27556 cx *= delay; //so we can have drawing re-done every frame,
28701 //previously it was for(0 to delay) advanceframes at end of loop
28702 27556 int32_t no_move = 0;
28703
28704 27556 currdmap = newdmap;
28705
4/4
✓ Branch 0 taken 27553 times.
✓ Branch 1 taken 1606497 times.
✓ Branch 2 taken 1606497 times.
✓ Branch 3 taken 27553 times.
1634050 for(word i = 0; cx >= 0 && delay != 0; i++, cx--) //Go!
28706 {
28707
2/2
✓ Branch 0 taken 1447121 times.
✓ Branch 1 taken 159376 times.
1606497 if (replay_version_check(0, 3))
28708 {
28709 159376 replay_poll();
28710 159376 }
28711
2/2
✓ Branch 0 taken 1606494 times.
✓ Branch 1 taken 3 times.
1606497 if(Quit)
28712 {
28713 3 screenscrolling = false;
28714 3 return;
28715 }
28716
28717
28718 1606494 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false);
28719
28720
2/2
✓ Branch 0 taken 1491550 times.
✓ Branch 1 taken 114944 times.
1606494 if(no_move > 0)
28721 114944 no_move--;
28722
28723 //Don't want to move things on the first or last iteration, or between delays
28724
6/6
✓ Branch 0 taken 1578938 times.
✓ Branch 1 taken 27556 times.
✓ Branch 2 taken 1538183 times.
✓ Branch 3 taken 40755 times.
✓ Branch 4 taken 33025 times.
✓ Branch 5 taken 1505158 times.
1606494 if(i == 0 || cx == 0 || cx % delay != 0)
28725 101336 no_move++;
28726
28727
4/4
✓ Branch 0 taken 1202636 times.
✓ Branch 1 taken 403858 times.
✓ Branch 2 taken 290276 times.
✓ Branch 3 taken 912360 times.
1606494 if(scrolldir == up || scrolldir == down)
28728 {
28729
2/2
✓ Branch 0 taken 644113 times.
✓ Branch 1 taken 50021 times.
694134 if(!get_qr(qr_SMOOTHVERTICALSCROLLING))
28730 {
28731 //Add a few extra frames if on the second loop and cool scrolling is not set
28732
2/2
✓ Branch 0 taken 49341 times.
✓ Branch 1 taken 680 times.
50021 if(i == 1)
28733 {
28734 680 cx += (scrolldir == down) ? 3 : 2;
28735 680 no_move += (scrolldir == down) ? 3 : 2;
28736 680 }
28737 50021 }
28738 else
28739 {
28740 //4 frames after we've finished scrolling of being still
28741
4/4
✓ Branch 0 taken 26404 times.
✓ Branch 1 taken 617709 times.
✓ Branch 2 taken 13202 times.
✓ Branch 3 taken 13202 times.
644113 if(cx == 0 && !end_frames)
28742 {
28743 13202 cx += 4;
28744 13202 no_move += 4;
28745 13202 end_frames = true;
28746 13202 }
28747 }
28748 694134 }
28749
28750 //Move Hero and the scroll position
28751
2/2
✓ Branch 0 taken 142497 times.
✓ Branch 1 taken 1463997 times.
1606494 if(!no_move)
28752 {
28753
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 332500 times.
✓ Branch 2 taken 246482 times.
✓ Branch 3 taken 414036 times.
✓ Branch 4 taken 470979 times.
1463997 switch(scrolldir)
28754 {
28755 case up:
28756 332500 sy -= step;
28757 332500 y += step;
28758 332500 break;
28759
28760 case down:
28761 246482 sy += step;
28762 246482 y -= step;
28763 246482 break;
28764
28765 case left:
28766 414036 sx -= step;
28767 414036 x += step;
28768 414036 break;
28769
28770 case right:
28771 470979 sx += step;
28772 470979 x -= step;
28773 470979 break;
28774 }
28775
28776 //bound Hero when me move him off the screen in the last couple of frames of scrolling
28777
2/2
✓ Branch 0 taken 29670 times.
✓ Branch 1 taken 1434327 times.
1463997 if(y > 160) y = 160;
28778
28779
2/2
✓ Branch 0 taken 21952 times.
✓ Branch 1 taken 1442045 times.
1463997 if(y < 0) y = 0;
28780
28781
2/2
✓ Branch 0 taken 25812 times.
✓ Branch 1 taken 1438185 times.
1463997 if(x > 240) x = 240;
28782
28783
2/2
✓ Branch 0 taken 29326 times.
✓ Branch 1 taken 1434671 times.
1463997 if(x < 0) x = 0;
28784
28785
4/4
✓ Branch 0 taken 1463751 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1463741 times.
1463997 if(ladderx > 0 || laddery > 0)
28786 {
28787 // If the ladder moves on both axes, the player can
28788 // gradually shift it by going back and forth
28789
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 if(scrolldir==up || scrolldir==down)
28790 laddery = y.getInt();
28791 else
28792 256 ladderx = x.getInt();
28793 256 }
28794 1463997 }
28795
28796 //Drawing
28797 1606494 tx = sx;
28798 1606494 ty = sy;
28799 1606494 tx2 = sx;
28800 1606494 ty2 = sy;
28801
28802
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 485490 times.
✓ Branch 2 taken 290276 times.
✓ Branch 3 taken 426870 times.
✓ Branch 4 taken 403858 times.
1606494 switch(scrolldir)
28803 {
28804 case right:
28805 485490 FFCore.ScrollingData[SCROLLDATA_NX] = 256-tx2;
28806 485490 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
28807 485490 FFCore.ScrollingData[SCROLLDATA_OX] = -tx2;
28808 485490 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28809 485490 tx -= 256;
28810 485490 break;
28811
28812 case down:
28813 290276 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
28814 290276 FFCore.ScrollingData[SCROLLDATA_NY] = 176-ty2;
28815 290276 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28816 290276 FFCore.ScrollingData[SCROLLDATA_OY] = -ty2;
28817 290276 ty -= 176;
28818 290276 break;
28819
28820 case left:
28821 426870 FFCore.ScrollingData[SCROLLDATA_NX] = -tx2;
28822 426870 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
28823 426870 FFCore.ScrollingData[SCROLLDATA_OX] = 256-tx2;
28824 426870 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28825 426870 tx2 -= 256;
28826 426870 break;
28827
28828 case up:
28829 403858 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
28830 403858 FFCore.ScrollingData[SCROLLDATA_NY] = -ty2;
28831 403858 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28832 403858 FFCore.ScrollingData[SCROLLDATA_OY] = 176-ty2;
28833 403858 ty2 -= 176;
28834 403858 break;
28835 }
28836
28837 //FFScript.OnWaitdraw()
28838 1606494 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
28839
28840 1606494 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
28841 1606494 clear_bitmap(scrollbuf);
28842 1606494 clear_bitmap(framebuf);
28843 1606494 clear_info_bmp();
28844
28845 1606494 combotile_add_x = 0;
28846 1606494 combotile_add_y = playing_field_offset;
28847
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 403858 times.
✓ Branch 2 taken 290276 times.
✓ Branch 3 taken 426870 times.
✓ Branch 4 taken 485490 times.
1606494 switch(scrolldir)
28848 {
28849 case up:
28850
2/2
✓ Branch 0 taken 403180 times.
✓ Branch 1 taken 678 times.
403858 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
28851
28852
2/2
✓ Branch 0 taken 403519 times.
✓ Branch 1 taken 339 times.
403858 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, -176+playing_field_offset, 3);
28853
28854
2/2
✓ Branch 0 taken 402673 times.
✓ Branch 1 taken 1185 times.
403858 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
28855
28856
2/2
✓ Branch 0 taken 402973 times.
✓ Branch 1 taken 885 times.
403858 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, -176+playing_field_offset, 3);
28857
28858 // Draw both screens' background layer primitives together, after both layers' combos.
28859 // Not ideal, but probably good enough for all realistic purposes.
28860
4/4
✓ Branch 0 taken 678 times.
✓ Branch 1 taken 403180 times.
✓ Branch 2 taken 402841 times.
✓ Branch 3 taken 1017 times.
403858 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
28861
28862
4/4
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 402673 times.
✓ Branch 2 taken 402423 times.
✓ Branch 3 taken 1435 times.
403858 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
28863
28864 403858 combotile_add_y -= sy;
28865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403858 times.
403858 if(lenscheck(newscr,0)) putscr(scrollbuf, 0, 0, newscr);
28866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403858 times.
403858 if(lenscheck(oldscr,0)) putscr(scrollbuf, 0, 176, oldscr);
28867 403858 break;
28868
28869 case down:
28870
2/2
✓ Branch 0 taken 290125 times.
✓ Branch 1 taken 151 times.
290276 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, -176+playing_field_offset, 2);
28871
28872
2/2
✓ Branch 0 taken 289938 times.
✓ Branch 1 taken 338 times.
290276 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
28873
28874
2/2
✓ Branch 0 taken 289826 times.
✓ Branch 1 taken 450 times.
290276 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, -176+playing_field_offset, 2);
28875
28876
2/2
✓ Branch 0 taken 289526 times.
✓ Branch 1 taken 750 times.
290276 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
28877
28878
4/4
✓ Branch 0 taken 151 times.
✓ Branch 1 taken 290125 times.
✓ Branch 2 taken 289787 times.
✓ Branch 3 taken 489 times.
290276 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
28879
28880
4/4
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 289826 times.
✓ Branch 2 taken 289376 times.
✓ Branch 3 taken 900 times.
290276 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
28881
28882 290276 combotile_add_y -= sy;
28883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290276 times.
290276 if(lenscheck(oldscr,0)) putscr(scrollbuf, 0, 0, oldscr);
28884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290276 times.
290276 if(lenscheck(newscr,0)) putscr(scrollbuf, 0, 176, newscr);
28885 290276 break;
28886
28887 case left:
28888
2/2
✓ Branch 0 taken 426852 times.
✓ Branch 1 taken 18 times.
426870 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
28889
28890
2/2
✓ Branch 0 taken 426804 times.
✓ Branch 1 taken 66 times.
426870 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, -256, playing_field_offset, 3);
28891
28892
2/2
✓ Branch 0 taken 425064 times.
✓ Branch 1 taken 1806 times.
426870 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
28893
28894
2/2
✓ Branch 0 taken 424998 times.
✓ Branch 1 taken 1872 times.
426870 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, -256, playing_field_offset, 3);
28895
28896
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 426852 times.
✓ Branch 2 taken 426786 times.
✓ Branch 3 taken 84 times.
426870 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
28897
28898
4/4
✓ Branch 0 taken 1806 times.
✓ Branch 1 taken 425064 times.
✓ Branch 2 taken 424602 times.
✓ Branch 3 taken 2268 times.
426870 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
28899
28900 426870 combotile_add_x -= sx;
28901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 426870 times.
426870 if(lenscheck(newscr,0)) putscr(scrollbuf, 0, 0, newscr);
28902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 426870 times.
426870 if(lenscheck(oldscr,0)) putscr(scrollbuf, 256, 0, oldscr);
28903 426870 break;
28904
28905 case right:
28906
1/2
✓ Branch 0 taken 485490 times.
✗ Branch 1 not taken.
485490 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, -256, playing_field_offset, 2);
28907
28908
2/2
✓ Branch 0 taken 485472 times.
✓ Branch 1 taken 18 times.
485490 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
28909
28910
2/2
✓ Branch 0 taken 483918 times.
✓ Branch 1 taken 1572 times.
485490 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, -256, playing_field_offset, 2);
28911
28912
2/2
✓ Branch 0 taken 483918 times.
✓ Branch 1 taken 1572 times.
485490 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
28913
28914
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 485490 times.
✓ Branch 2 taken 485472 times.
✓ Branch 3 taken 18 times.
485490 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
28915
28916
4/4
✓ Branch 0 taken 1572 times.
✓ Branch 1 taken 483918 times.
✓ Branch 2 taken 483456 times.
✓ Branch 3 taken 2034 times.
485490 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
28917
28918 485490 combotile_add_x -= sx;
28919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 485490 times.
485490 if(lenscheck(oldscr,0)) putscr(scrollbuf, 0, 0, oldscr);
28920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 485490 times.
485490 if(lenscheck(newscr,0)) putscr(scrollbuf, 256, 0, newscr);
28921 485490 break;
28922 }
28923
28924 1606494 combotile_add_x = 0;
28925 1606494 combotile_add_y = 0;
28926
28927 1606494 blit(scrollbuf, framebuf, sx, sy, 0, playing_field_offset, 256, 168);
28928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1606494 times.
1606494 if(lenscheck(newscr,0))
28929 1606494 do_primitives(framebuf, 0, newscr, 0, playing_field_offset);
28930
28931 1606494 do_layer(framebuf, 0, 1, oldscr, tx2, ty2, 3);
28932 1606494 do_layer(framebuf, 0, 1, newscr, tx, ty, 2, false, true);
28933
28934
2/2
✓ Branch 0 taken 1160704 times.
✓ Branch 1 taken 445790 times.
1606494 if(get_qr(qr_FFCSCROLL))
28935 {
28936 445790 do_layer(framebuf, -3, 0, oldscr, tx2, ty2, 3, true); //ffcs
28937 445790 do_layer(framebuf, -3, 0, newscr, tx, ty, 2, true);
28938 445790 }
28939
28940
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 1605733 times.
1606494 if(!(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) ) do_layer(framebuf, 0, 2, oldscr, tx2, ty2, 3);
28941
2/2
✓ Branch 0 taken 847 times.
✓ Branch 1 taken 1605647 times.
1606494 if(!(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, newscr, tx, ty, 2, false, !(oldscr->flags7&fLAYER2BG));
28942
28943 //push blocks
28944
2/2
✓ Branch 0 taken 16458 times.
✓ Branch 1 taken 1590036 times.
1606494 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
28945 {
28946 1590036 do_layer(framebuf, -2, 0, oldscr, tx2, ty2, 3);
28947 1590036 do_layer(framebuf, -2, 0, newscr, tx, ty, 2);
28948
2/2
✓ Branch 0 taken 1549880 times.
✓ Branch 1 taken 40156 times.
1590036 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
28949 {
28950 40156 do_layer(framebuf, -2, 1, oldscr, tx2, ty2, 3);
28951 40156 do_layer(framebuf, -2, 1, newscr, tx, ty, 2);
28952 40156 do_layer(framebuf, -2, 2, oldscr, tx2, ty2, 3);
28953 40156 do_layer(framebuf, -2, 2, newscr, tx, ty, 2);
28954 40156 }
28955 1590036 do_primitives(framebuf, SPLAYER_PUSHBLOCK, newscr, 0, playing_field_offset);
28956 1590036 }
28957
28958 1606494 do_walkflags(oldscr, tx2, ty2,3); //show walkflags if the cheat is on
28959 1606494 do_walkflags(newscr, tx, ty,2);
28960
28961 1606494 do_effectflags(oldscr, tx2, ty2,3); //show effectflags if the cheat is on
28962 1606494 do_effectflags(newscr, tx, ty,2);
28963
28964
28965 1606494 putscrdoors(framebuf, 0-tx2, 0-ty2+playing_field_offset, oldscr);
28966 1606494 putscrdoors(framebuf, 0-tx, 0-ty+playing_field_offset, newscr);
28967 1606494 herostep();
28968
1/2
✓ Branch 0 taken 1606494 times.
✗ Branch 1 not taken.
1606494 if(isForceFaceUp) dir = up;
28969
28970
5/6
✓ Branch 0 taken 1605730 times.
✓ Branch 1 taken 764 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1604966 times.
✓ Branch 4 taken 1605730 times.
✓ Branch 5 taken 1605730 times.
1606494 if((z > 0 || fakez > 0) && (!get_qr(qr_SHADOWSFLICKER) || frame&1))
28971 {
28972 3210696 drawshadow(framebuf, get_qr(qr_TRANSSHADOWS) != 0);
28973 3210696 }
28974
28975
4/4
✓ Branch 0 taken 615817 times.
✓ Branch 1 taken 990677 times.
✓ Branch 2 taken 295458 times.
✓ Branch 3 taken 320359 times.
1606494 if(!isdungeon() || get_qr(qr_FREEFORM))
28976 {
28977 1286135 draw_under(framebuf); //draw the ladder or raft
28978 1286135 decorations.draw2(framebuf, true);
28979 1286135 draw(framebuf); //Hero
28980 1286135 decorations.draw(framebuf, true);
28981 1286135 }
28982
28983
2/2
✓ Branch 0 taken 5079 times.
✓ Branch 1 taken 1601415 times.
1606494 if(!(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, oldscr, tx2, ty2, 3);
28984
28985 1606494 do_layer(framebuf, 0, 4, oldscr, tx2, ty2, 3); //layer 4
28986 1606494 do_layer(framebuf, -1, 0, oldscr, tx2, ty2, 3); //overhead combos
28987
2/2
✓ Branch 0 taken 1561882 times.
✓ Branch 1 taken 44612 times.
1606494 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
28988 {
28989 44612 do_layer(framebuf, -1, 1, oldscr, tx2, ty2, 3); //overhead combos
28990 44612 do_layer(framebuf, -1, 2, oldscr, tx2, ty2, 3); //overhead combos
28991 44612 }
28992 1606494 do_layer(framebuf, 0, 5, oldscr, tx2, ty2, 3); //layer 5
28993 1606494 do_layer(framebuf, -4, 0, oldscr, tx2, ty2, 3, true); //overhead FFCs
28994 1606494 do_layer(framebuf, 0, 6, oldscr, tx2, ty2, 3); //layer 6
28995
28996
2/2
✓ Branch 0 taken 5013 times.
✓ Branch 1 taken 1601481 times.
1606494 if(!(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, newscr, tx, ty, 2, false, !(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)));
28997
28998 1606494 do_layer(framebuf, 0, 4, newscr, tx, ty, 2, false, true); //layer 4
28999 1606494 do_layer(framebuf, -1, 0, newscr, tx, ty, 2); //overhead combos
29000
2/2
✓ Branch 0 taken 1561882 times.
✓ Branch 1 taken 44612 times.
1606494 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
29001 {
29002 44612 do_layer(framebuf, -1, 1, newscr, tx, ty, 2); //overhead combos
29003 44612 do_layer(framebuf, -1, 2, newscr, tx, ty, 2); //overhead combos
29004 44612 }
29005 1606494 do_layer(framebuf, 0, 5, newscr, tx, ty, 2, false, true); //layer 5
29006 1606494 do_layer(framebuf, -4, 0, newscr, tx, ty, 2, true); //overhead FFCs
29007 1606494 do_layer(framebuf, 0, 6, newscr, tx, ty, 2, false, true); //layer 6
29008
29009
29010
1/2
✓ Branch 0 taken 1606494 times.
✗ Branch 1 not taken.
1606494 if(msg_bg_display_buf->clip == 0)
29011 {
29012 blit_msgstr_bg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
29013 }
29014
1/2
✓ Branch 0 taken 1606494 times.
✗ Branch 1 not taken.
1606494 if(msg_portrait_display_buf->clip == 0)
29015 {
29016 blit_msgstr_prt(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
29017 }
29018
1/2
✓ Branch 0 taken 1606494 times.
✗ Branch 1 not taken.
1606494 if(msg_txt_display_buf->clip == 0)
29019 {
29020 blit_msgstr_fg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
29021 }
29022
29023
6/6
✓ Branch 0 taken 50906 times.
✓ Branch 1 taken 1555588 times.
✓ Branch 2 taken 42063 times.
✓ Branch 3 taken 8843 times.
✓ Branch 4 taken 239 times.
✓ Branch 5 taken 41824 times.
1606494 if(get_qr(qr_NEW_DARKROOM) && (room_is_dark||room_was_dark))
29024 {
29025 9082 clear_darkroom_bitmaps();
29026 9082 calc_darkroom_combos(true);
29027 9082 calc_darkroom_hero(FFCore.ScrollingData[SCROLLDATA_NX], FFCore.ScrollingData[SCROLLDATA_NY],FFCore.ScrollingData[SCROLLDATA_OX], FFCore.ScrollingData[SCROLLDATA_OY]);
29028 9082 }
29029
29030
4/4
✓ Branch 0 taken 50906 times.
✓ Branch 1 taken 1555588 times.
✓ Branch 2 taken 14411 times.
✓ Branch 3 taken 36495 times.
1606494 if(get_qr(qr_NEW_DARKROOM) && get_qr(qr_NEWDARK_L6))
29031 {
29032 36495 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
29033 36495 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
29034 36495 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
29035
2/2
✓ Branch 0 taken 28127 times.
✓ Branch 1 taken 8368 times.
36495 if(room_is_dark)
29036 {
29037
1/2
✓ Branch 0 taken 8368 times.
✗ Branch 1 not taken.
8368 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
29038 {
29039 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
29040 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
29041 }
29042
29043 8368 color_map = &trans_table2;
29044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8368 times.
8368 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
29045 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
29046 else
29047 8368 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
29048 8368 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
29049 8368 color_map = &trans_table;
29050 8368 }
29051
2/2
✓ Branch 0 taken 28199 times.
✓ Branch 1 taken 8296 times.
36495 if(room_was_dark)
29052 {
29053
1/2
✓ Branch 0 taken 8296 times.
✗ Branch 1 not taken.
8296 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
29054 {
29055 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
29056 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
29057 }
29058
29059 8296 color_map = &trans_table2;
29060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8296 times.
8296 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
29061 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
29062 else
29063 8296 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
29064 8296 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
29065 8296 color_map = &trans_table;
29066 8296 }
29067 36495 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
29068 36495 }
29069 1606494 put_passive_subscr(framebuf, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
29070
2/2
✓ Branch 0 taken 1032853 times.
✓ Branch 1 taken 573641 times.
1606494 if(get_qr(qr_SUBSCREENOVERSPRITES))
29071 573641 do_primitives(framebuf, 7, newscr, 0, playing_field_offset);
29072
29073
4/4
✓ Branch 0 taken 50906 times.
✓ Branch 1 taken 1555588 times.
✓ Branch 2 taken 36495 times.
✓ Branch 3 taken 14411 times.
1606494 if(get_qr(qr_NEW_DARKROOM) && !get_qr(qr_NEWDARK_L6))
29074 {
29075 14411 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
29076 14411 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
29077 14411 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
29078
2/2
✓ Branch 0 taken 13936 times.
✓ Branch 1 taken 475 times.
14411 if(room_is_dark)
29079 {
29080
1/2
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
475 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
29081 {
29082 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
29083 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
29084 }
29085
29086 475 color_map = &trans_table2;
29087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
29088 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
29089 else
29090 475 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
29091 475 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
29092 475 color_map = &trans_table;
29093 475 }
29094
2/2
✓ Branch 0 taken 13970 times.
✓ Branch 1 taken 441 times.
14411 if(room_was_dark)
29095 {
29096
1/2
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
441 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
29097 {
29098 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
29099 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
29100 }
29101
29102 441 color_map = &trans_table2;
29103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 441 times.
441 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
29104 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
29105 else
29106 441 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
29107 441 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
29108 441 color_map = &trans_table;
29109 441 }
29110 14411 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
29111 14411 }
29112 1606494 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
29113
29114 //end drawing
29115 1606494 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
29116 1606494 advanceframe(true/*,true,false*/);
29117
29118 //Don't clear the last frame, unless 'fixed'
29119
4/4
✓ Branch 0 taken 27553 times.
✓ Branch 1 taken 1578941 times.
✓ Branch 2 taken 1720 times.
✓ Branch 3 taken 25833 times.
1606494 if(cx > 0 || get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
29120 1580661 script_drawing_commands.Clear();
29121 1606494 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
29122 1606494 actiontype lastaction = action;
29123 1606494 action=scrolling; FFCore.setHeroAction(scrolling);
29124 1606494 FFCore.runF6Engine();
29125 1606494 action=lastaction; FFCore.setHeroAction(lastaction);
29126 1606494 } //end main scrolling loop
29127 27553 currdmap = olddmap;
29128
29129 27553 clear_bitmap(msg_txt_display_buf);
29130 27553 set_clip_state(msg_txt_display_buf, 1);
29131 27553 clear_bitmap(msg_bg_display_buf);
29132 27553 set_clip_state(msg_bg_display_buf, 1);
29133 27553 clear_bitmap(msg_portrait_display_buf);
29134 27553 set_clip_state(msg_portrait_display_buf, 1);
29135
29136 //Move hero to the other side of the screen if scrolling's not turned on
29137
1/2
✓ Branch 0 taken 27553 times.
✗ Branch 1 not taken.
27553 if(get_qr(qr_NOSCROLL))
29138 {
29139 switch(scrolldir)
29140 {
29141 case up:
29142 y = 160;
29143 break;
29144
29145 case down:
29146 y = 0;
29147 break;
29148
29149 case left:
29150 x = 240;
29151 break;
29152
29153 case right:
29154 x = 0;
29155 break;
29156 }
29157 }
29158
29159
3/4
✓ Branch 0 taken 27539 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 27553 times.
✗ Branch 3 not taken.
27553 if((z > 0 || fakez > 0) && isSideViewHero())
29160 {
29161 y -= z;
29162 y -= fakez;
29163 z = 0;
29164 fakez = 0;
29165 }
29166
29167 27553 combotile_add_x = 0;
29168 27553 combotile_add_y = 0;
29169
29170 27553 set_respawn_point(false);
29171 27553 trySideviewLadder();
29172 27553 warpx = -1;
29173 27553 warpy = -1;
29174
29175 27553 screenscrolling = false;
29176 27553 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
29177 27553 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
29178 27553 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
29179 27553 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
29180 27553 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
29181
29182
2/2
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 26591 times.
27553 if(destdmap != -1)
29183 {
29184 962 bool changedlevel = false;
29185 962 bool changeddmap = false;
29186
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 823 times.
962 if(olddmap != destdmap)
29187 {
29188 823 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
29189 823 changeddmap = true;
29190 823 }
29191
2/2
✓ Branch 0 taken 818 times.
✓ Branch 1 taken 144 times.
962 if(DMaps[olddmap].level != DMaps[destdmap].level)
29192 {
29193 144 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
29194 144 changedlevel = true;
29195 144 }
29196 962 dlevel = DMaps[destdmap].level;
29197 962 currdmap = destdmap;
29198
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 823 times.
962 if(changeddmap)
29199 {
29200 823 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
29201 823 }
29202
2/2
✓ Branch 0 taken 818 times.
✓ Branch 1 taken 144 times.
962 if(changedlevel)
29203 {
29204 144 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
29205 144 }
29206 962 }
29207
29208 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
29209 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
29210 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
29211 //direction. -DD
29212
29213
2/2
✓ Branch 0 taken 27205 times.
✓ Branch 1 taken 348 times.
27553 if(nowinwater)
29214 {
29215 348 SetSwim();
29216 348 hopclk = 0xFF;
29217 348 }
29218
29219 // NES behaviour: Fade to light after scrolling
29220 27553 lighting(false, false); // No, we don't need to set naturaldark...
29221
29222 27553 init_dmap();
29223 27553 putscr(scrollbuf,0,0,newscr);
29224 27553 putscrdoors(scrollbuf,0,0,newscr);
29225
29226 // Check for raft flags
29227
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 26395 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 25558 times.
53168 if((get_qr(qr_BROKEN_RAFT_SCROLL) || lastaction == rafting)
29228
4/4
✓ Branch 0 taken 25941 times.
✓ Branch 1 taken 1612 times.
✓ Branch 2 taken 25615 times.
✓ Branch 3 taken 326 times.
27553 && action!=rafting && hopclk==0 && !toogam)
29229 {
29230
3/4
✓ Branch 0 taken 25553 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25553 times.
25558 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
29231 {
29232 5 sfx(tmpscr->secretsfx);
29233 5 action=rafting; FFCore.setHeroAction(rafting);
29234 5 raftclk=0;
29235 5 }
29236
29237 // Half a tile off?
29238
6/8
✓ Branch 0 taken 19392 times.
✓ Branch 1 taken 6161 times.
✓ Branch 2 taken 6918 times.
✓ Branch 3 taken 12474 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13079 times.
✓ Branch 6 taken 25553 times.
✗ Branch 7 not taken.
38632 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
29239 {
29240 sfx(tmpscr->secretsfx);
29241 action=rafting; FFCore.setHeroAction(rafting);
29242 raftclk=0;
29243 }
29244 25558 }
29245
29246 27553 opendoors=0;
29247 27553 markBmap(-1);
29248
29249
2/2
✓ Branch 0 taken 18848 times.
✓ Branch 1 taken 8705 times.
27553 if(isdungeon())
29250 {
29251
4/4
✓ Branch 0 taken 5101 times.
✓ Branch 1 taken 1694 times.
✓ Branch 2 taken 1904 times.
✓ Branch 3 taken 6 times.
8705 switch(tmpscr->door[scrolldir^1])
29252 {
29253 case dNONE:
29254 6 dir = scrolldir;
29255 6 break;
29256 case dOPEN:
29257 case dUNLOCKED:
29258 case dOPENBOSS:
29259 5101 dir = scrolldir;
29260
29261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5101 times.
5101 if(action!=rafting)
29262 5101 stepforward(diagonalMovement?11:12, false);
29263
29264 5101 break;
29265
29266 case dSHUTTER:
29267 case d1WAYSHUTTER:
29268 1694 dir = scrolldir;
29269
29270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
1694 if(action!=rafting)
29271 1694 stepforward(diagonalMovement?21:24, false);
29272
29273 1694 putdoor(scrollbuf,0,scrolldir^1,tmpscr->door[scrolldir^1]);
29274 1694 opendoors=-4;
29275 1694 sfx(WAV_DOOR);
29276 1694 break;
29277
29278 default:
29279 1904 dir = scrolldir;
29280
29281
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1857 times.
1904 if(action!=rafting)
29282 1857 stepforward(diagonalMovement?21:24, false);
29283 1904 }
29284 8705 }
29285
29286
1/2
✓ Branch 0 taken 27553 times.
✗ Branch 1 not taken.
27553 if(isForceFaceUp) dir = up;
29287
29288
1/2
✓ Branch 0 taken 27553 times.
✗ Branch 1 not taken.
27553 if(action == scrolling)
29289 {
29290 action=none; FFCore.setHeroAction(none);
29291 }
29292
29293
3/4
✓ Branch 0 taken 27521 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27521 times.
27553 if(action != attacking && action != sideswimattacking)
29294 {
29295 27521 charging = 0;
29296 27521 tapping = false;
29297 27521 }
29298
29299 27553 map_bkgsfx(true);
29300
29301
2/2
✓ Branch 0 taken 27519 times.
✓ Branch 1 taken 34 times.
27553 if(newscr->flags2&fSECRET)
29302 {
29303 34 sfx(newscr->secretsfx);
29304 34 }
29305
29306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27553 times.
27553 if (updatemusic)
29307 {
29308 27553 playLevelMusic();
29309
1/2
✓ Branch 0 taken 27553 times.
✗ Branch 1 not taken.
27553 if (musicrevert)
29310 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
29311 27553 }
29312
29313 27553 newscr_clk = frame;
29314 27553 activated_timed_warp=false;
29315 27553 loadside = scrolldir^1;
29316 27553 FFCore.clear_combo_scripts();
29317 27553 eventlog_mapflags();
29318 27553 decorations.animate(); //continue to animate tall grass during scrolling
29319
2/2
✓ Branch 0 taken 25833 times.
✓ Branch 1 taken 1720 times.
27553 if(get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
29320 {
29321
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 1670 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 44 times.
1720 if(olddmap == newdmap || (replay_version_check(0, 15)))
29322 {
29323 1676 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
29324 1676 }
29325 1720 }
29326
2/2
✓ Branch 0 taken 26112 times.
✓ Branch 1 taken 1441 times.
27553 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
29327 1441 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
29328 27556 }
29329
29330
29331
29332 // How much to reduce Hero's damage, taking into account various rings.
29333 15150 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
29334 {
29335
1/2
✓ Branch 0 taken 15150 times.
✗ Branch 1 not taken.
15150 if(dmg < 0) return dmg; //Don't reduce healing
29336
2/2
✓ Branch 0 taken 14423 times.
✓ Branch 1 taken 727 times.
15150 if ( get_qr(qr_BROKEN_RING_POWER) )
29337 {
29338 14423 int32_t divisor = 1;
29339 14423 float percentage = 1;
29340 14423 int32_t itemid = current_item_id(itype_ring);
29341 14423 bool usering = false;
29342
29343
4/4
✓ Branch 0 taken 10812 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 324 times.
✓ Branch 3 taken 10488 times.
14423 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
29344 {
29345 10488 usering = true;
29346 10488 paymagiccost(itemid);
29347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10488 times.
10488 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
29348 {
29349 percentage *= itemsbuf[itemid].power/100.0;
29350 }
29351 else
29352 {
29353 10488 divisor *= itemsbuf[itemid].power;
29354 }
29355 10488 }
29356
29357 /* Now for the Peril Ring */
29358 14423 itemid = current_item_id(itype_perilring);
29359
29360
8/10
✓ Branch 0 taken 2844 times.
✓ Branch 1 taken 11579 times.
✓ Branch 2 taken 2698 times.
✓ Branch 3 taken 146 times.
✓ Branch 4 taken 402 times.
✓ Branch 5 taken 2296 times.
✓ Branch 6 taken 402 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 402 times.
14423 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
29361 {
29362 402 usering = true;
29363 402 paymagiccost(itemid);
29364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
402 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
29365 {
29366 percentage *= itemsbuf[itemid].power/100.0;
29367 }
29368 else
29369 {
29370 402 divisor *= itemsbuf[itemid].power;
29371 }
29372 402 }
29373
29374 // Ring divisor of 0 = no damage. -L
29375
4/6
✓ Branch 0 taken 10506 times.
✓ Branch 1 taken 3917 times.
✓ Branch 2 taken 10506 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10506 times.
14423 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
29376 return 0;
29377
29378
1/2
✓ Branch 0 taken 14423 times.
✗ Branch 1 not taken.
14423 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
29379
29380
1/2
✓ Branch 0 taken 14423 times.
✗ Branch 1 not taken.
14423 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
29381
1/2
✓ Branch 0 taken 14423 times.
✗ Branch 1 not taken.
14423 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
29382
29383 }
29384 else
29385 {
29386 727 double divisor = 1;
29387 727 double percentage = 1;
29388 727 int32_t itemid = current_item_id(itype_ring);
29389 727 bool usering = false;
29390
29391
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 724 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
727 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
29392 {
29393 3 usering = true;
29394 3 paymagiccost(itemid);
29395
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
29396 {
29397 1 double perc = itemsbuf[itemid].power/100.0;
29398
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
29399 1 percentage *= perc;
29400 1 }
29401 else
29402 {
29403
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].power < 0)
29404 divisor /= -(itemsbuf[itemid].power);
29405 2 else divisor *= itemsbuf[itemid].power;
29406 }
29407 3 }
29408
29409 /* Now for the Peril Ring */
29410 727 itemid = current_item_id(itype_perilring);
29411
29412
4/10
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 725 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
727 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
29413 {
29414 usering = true;
29415 paymagiccost(itemid);
29416 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
29417 {
29418 double perc = itemsbuf[itemid].power/100.0;
29419 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
29420 percentage *= perc;
29421 }
29422 else
29423 {
29424 if(itemsbuf[itemid].power < 0)
29425 divisor /= -(itemsbuf[itemid].power);
29426 else divisor *= itemsbuf[itemid].power;
29427 }
29428 }
29429
29430 // Ring divisor of 0 = no damage. -L
29431
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 724 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
727 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
29432 return 0;
29433
29434 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
29435
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
29436 }
29437 15150 }
29438
29439 // Should swinging the hammer make the 'pound' sound?
29440 // Or is Hero just hitting air?
29441 6470 bool HeroClass::sideviewhammerpound()
29442 {
29443 6470 int32_t wx=0,wy=0;
29444
29445
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1022 times.
✓ Branch 2 taken 1520 times.
✓ Branch 3 taken 2131 times.
✓ Branch 4 taken 1797 times.
6470 switch(dir)
29446 {
29447 case up:
29448 1022 wx=-1;
29449 1022 wy=-15;
29450
29451
1/2
✓ Branch 0 taken 1022 times.
✗ Branch 1 not taken.
1022 if(isSideViewHero()) wy+=8;
29452
29453 1022 break;
29454
29455 case down:
29456 1520 wx=8;
29457 1520 wy=28;
29458
29459
1/2
✓ Branch 0 taken 1520 times.
✗ Branch 1 not taken.
1520 if(isSideViewHero()) wy-=8;
29460
29461 1520 break;
29462
29463 case left:
29464 2131 wx=-8;
29465 2131 wy=14;
29466
29467
2/2
✓ Branch 0 taken 2125 times.
✓ Branch 1 taken 6 times.
2131 if(isSideViewHero()) wy+=8;
29468
29469 2131 break;
29470
29471 case right:
29472 1797 wx=21;
29473 1797 wy=14;
29474
29475
1/2
✓ Branch 0 taken 1797 times.
✗ Branch 1 not taken.
1797 if(isSideViewHero()) wy+=8;
29476
29477 1797 break;
29478 }
29479
29480
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6464 times.
6470 if(!isSideViewHero())
29481 {
29482
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 6455 times.
6464 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex(MAPCOMBO(x+wx,y+wy), currmap, currscr, -1, x+wx,y+wy));
29483 }
29484
29485
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
29486
29487 if(dir==left || dir==right)
29488 {
29489 wx+=16;
29490
29491 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
29492 }
29493
29494 return false;
29495 6470 }
29496
29497 /************************************/
29498 /******** More Items Code *********/
29499 /************************************/
29500
29501 // The following are only used for Hero damage. Damage is in quarter hearts.
29502 9127 int32_t enemy_dp(int32_t index)
29503 {
29504 9127 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
29505 }
29506
29507 5414 int32_t ewpn_dp(int32_t index)
29508 {
29509 5414 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
29510 }
29511
29512 43 int32_t lwpn_dp(int32_t index)
29513 {
29514 43 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
29515 }
29516
29517 135912436 bool checkbunny(int32_t itemid)
29518 {
29519
3/4
✓ Branch 0 taken 135826352 times.
✓ Branch 1 taken 86084 times.
✓ Branch 2 taken 86084 times.
✗ Branch 3 not taken.
135912436 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&ITEM_BUNNY_ENABLED);
29520 }
29521
29522 49108427 bool usesSwordJinx(int32_t itemid)
29523 {
29524 49108427 itemdata const& it = itemsbuf[itemid];
29525 49108427 bool ret = (it.family==itype_sword);
29526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49108427 times.
49108427 if(it.flags & ITEM_FLIP_JINX) return !ret;
29527 49108427 return ret;
29528 49108427 }
29529 40175492 bool checkitem_jinx(int32_t itemid)
29530 {
29531 40175492 itemdata const& it = itemsbuf[itemid];
29532
2/2
✓ Branch 0 taken 6225 times.
✓ Branch 1 taken 40169267 times.
40175492 if(it.flags & ITEM_JINX_IMMUNE) return true;
29533
2/2
✓ Branch 0 taken 8334301 times.
✓ Branch 1 taken 31834966 times.
40169267 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
29534 31834966 return HeroItemClk() == 0;
29535 40175492 }
29536
29537 2 void stopCaneOfByrna()
29538 {
29539
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2 times.
42 for(int32_t i=0; i<Lwpns.Count(); i++)
29540 {
29541 40 weapon *w = ((weapon*)Lwpns.spr(i));
29542
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 2 times.
40 if(w->id==wCByrna)
29543 2 w->dead=1;
29544 40 }
29545 2 }
29546
29547 /* Crashes if used by ffscript.cpp, in case LINKITEMD
29548 void stopCaneOfByrna()
29549 {
29550 byte prnt_cane = -1;
29551 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
29552 prnt_cane = ew->parentitem;
29553 for(int32_t i=0; i<Lwpns.Count(); i++)
29554 {
29555 weapon *w = ((weapon*)Lwpns.spr(i));
29556
29557 if(w->id==wCByrna)
29558 {
29559 w->dead=1;
29560 }
29561 }
29562 if ( prnt_cane > -1 )
29563 {
29564 stop_sfx(itemsbuf[prnt_cane].usesound);
29565 }
29566 }
29567 */
29568 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
29569 14161771 void HeroClass::cleanupByrna()
29570 {
29571
2/2
✓ Branch 0 taken 14161694 times.
✓ Branch 1 taken 77 times.
14161771 if ( last_cane_of_byrna_item_id > -1 )
29572 {
29573 //al_trace("Last cane id is: %d\n", last_cane_of_byrna_item_id);
29574
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 75 times.
77 if ( !(Lwpns.idCount(wCByrna)) )
29575 {
29576 2 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
29577 2 last_cane_of_byrna_item_id = -1;
29578 2 }
29579 77 }
29580 14161771 }
29581
29582 // Used to find out if an item family is attached to one of the buttons currently pressed.
29583 4413369 bool isWpnPressed(int32_t itype)
29584 {
29585
4/4
✓ Branch 0 taken 527481 times.
✓ Branch 1 taken 3885888 times.
✓ Branch 2 taken 463038 times.
✓ Branch 3 taken 64443 times.
4413369 if((itype==getItemFamily(itemsbuf,Bwpn)) && DrunkcBbtn()) return true;
29586
4/4
✓ Branch 0 taken 1585312 times.
✓ Branch 1 taken 2763614 times.
✓ Branch 2 taken 652806 times.
✓ Branch 3 taken 932506 times.
4348926 if((itype==getItemFamily(itemsbuf,Awpn)) && DrunkcAbtn()) return true;
29587
4/4
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 3414990 times.
✓ Branch 2 taken 566 times.
✓ Branch 3 taken 864 times.
3416420 if((itype==getItemFamily(itemsbuf,Xwpn)) && DrunkcEx1btn()) return true;
29588
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 3415494 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 27 times.
3415556 if((itype==getItemFamily(itemsbuf,Ywpn)) && DrunkcEx2btn()) return true;
29589 3415521 return false;
29590 4413369 }
29591
29592 13594615 int32_t getWpnPressed(int32_t itype)
29593 {
29594
4/4
✓ Branch 0 taken 402438 times.
✓ Branch 1 taken 13192177 times.
✓ Branch 2 taken 393732 times.
✓ Branch 3 taken 8706 times.
13594615 if((itype==getItemFamily(itemsbuf,Bwpn)) && DrunkcBbtn()) return Bwpn&0xFFF;
29595
3/4
✓ Branch 0 taken 28064 times.
✓ Branch 1 taken 13557845 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28064 times.
13585909 if((itype==getItemFamily(itemsbuf,Awpn)) && DrunkcAbtn()) return Awpn&0xFFF;
29596
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13557845 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13557845 if((itype==getItemFamily(itemsbuf,Xwpn)) && DrunkcEx1btn()) return Xwpn&0xFFF;
29597
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13557845 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13557845 if((itype==getItemFamily(itemsbuf,Ywpn)) && DrunkcEx2btn()) return Ywpn&0xFFF;
29598
29599 13557845 return -1;
29600 13594615 }
29601
29602 14164265 int32_t getRocsPressed()
29603 {
29604 14164265 int32_t jumpid = current_item_id(itype_rocs,true,true);
29605
29606
2/2
✓ Branch 0 taken 352076 times.
✓ Branch 1 taken 13812189 times.
14164265 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
29607
29608
2/2
✓ Branch 0 taken 13812189 times.
✓ Branch 1 taken 352076 times.
14164265 if (jumpid != -1)
29609 {
29610 352076 itemdata const& itm = itemsbuf[jumpid];
29611
29612 352076 byte intbtn = byte(itm.misc2&0xFF);
29613
1/2
✓ Branch 0 taken 352076 times.
✗ Branch 1 not taken.
352076 if(getIntBtnInput(intbtn, false, true, false, false, true))
29614 return jumpid; //not pressed
29615 352076 }
29616
29617
4/4
✓ Branch 0 taken 124977 times.
✓ Branch 1 taken 14039288 times.
✓ Branch 2 taken 118917 times.
✓ Branch 3 taken 6060 times.
14164265 if((itype_rocs==getItemFamily(itemsbuf,Bwpn)) && DrunkcBbtn())
29618 6060 return Bwpn;
29619
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14158205 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14158205 if((itype_rocs==getItemFamily(itemsbuf,Awpn)) && DrunkcAbtn())
29620 return Awpn;
29621
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14158205 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14158205 if((itype_rocs==getItemFamily(itemsbuf,Xwpn)) && DrunkcEx1btn())
29622 return Xwpn;
29623
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14158205 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14158205 if((itype_rocs==getItemFamily(itemsbuf,Ywpn)) && DrunkcEx2btn())
29624 return Ywpn;
29625
29626 14158205 return -1;
29627 14164265 }
29628
29629 bool isItmPressed(int32_t itmid)
29630 {
29631 if(itmid==(NEG_OR_MASK(Bwpn,0xFFF)) && DrunkcBbtn()) return true;
29632 if(itmid==(NEG_OR_MASK(Awpn,0xFFF)) && DrunkcAbtn()) return true;
29633 if(itmid==(NEG_OR_MASK(Xwpn,0xFFF)) && DrunkcEx1btn()) return true;
29634 if(itmid==(NEG_OR_MASK(Ywpn,0xFFF)) && DrunkcEx2btn()) return true;
29635 return false;
29636 }
29637
29638 //helper function
29639 23779 static void selectNextBTNWpn(int32_t type, word& wpos, int32_t& BTNwpn,
29640 int32_t& directItemBTN, word f1 = 255, word f2 = 255, word f3 = 255)
29641 {
29642
1/2
✓ Branch 0 taken 23779 times.
✗ Branch 1 not taken.
23779 if(!new_subscreen_active)
29643 return;
29644 23779 byte pgn = wpos&0xFF, pos = wpos>>8;
29645 23779 bool empty = pgn==255;
29646
3/4
✓ Branch 0 taken 9898 times.
✓ Branch 1 taken 13881 times.
✓ Branch 2 taken 9898 times.
✗ Branch 3 not taken.
23779 if(empty && get_qr(qr_NO_BUTTON_VERIFY)) return; //intentional nothingness
29647
2/2
✓ Branch 0 taken 9898 times.
✓ Branch 1 taken 13881 times.
23779 SubscrPage* pg = new_subscreen_active->get_page(pgn==255?new_subscreen_active->curpage:pgn);
29648
1/2
✓ Branch 0 taken 23779 times.
✗ Branch 1 not taken.
23779 if(!pg)
29649 return;
29650
4/6
✓ Branch 0 taken 22490 times.
✓ Branch 1 taken 1289 times.
✓ Branch 2 taken 1289 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1289 times.
23779 auto fp1 = ((f1&0xFF)==255) ? 255 : ((empty || (f1&0xFF)==(wpos&0xFF)) ? f1 : 255);
29651
4/6
✓ Branch 0 taken 23775 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
23779 auto fp2 = ((f2&0xFF)==255) ? 255 : ((empty || (f2&0xFF)==(wpos&0xFF)) ? f2 : 255);
29652
4/6
✓ Branch 0 taken 23775 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
23779 auto fp3 = ((f3&0xFF)==255) ? 255 : ((empty || (f3&0xFF)==(wpos&0xFF)) ? f3 : 255);
29653 23779 auto ret = pg->movepos_legacy(type, wpos, fp1, fp2, fp3);
29654
2/2
✓ Branch 0 taken 9898 times.
✓ Branch 1 taken 13881 times.
23779 if((ret&0xFF) == 0xFF)
29655 9898 BTNwpn = -1;
29656 13881 else BTNwpn = pg->get_item_pos(ret>>8);
29657
2/2
✓ Branch 0 taken 13881 times.
✓ Branch 1 taken 9898 times.
23779 directItemBTN = NEG_OR_MASK(BTNwpn,0xFFF);
29658 23779 wpos = ret;
29659 23779 }
29660 5585 void selectNextAWpn(int32_t type)
29661 {
29662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5585 times.
5585 if(!get_qr(qr_SELECTAWPN))
29663 return;
29664
2/4
✓ Branch 0 taken 5585 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5585 times.
5585 selectNextBTNWpn(type, game->awpn, Awpn, directItemA, COND_BWPN, COND_XWPN, COND_YWPN);
29665 5585 }
29666
29667 18194 void selectNextBWpn(int32_t type)
29668 {
29669
1/2
✓ Branch 0 taken 18194 times.
✗ Branch 1 not taken.
18194 if(!new_subscreen_active)
29670 return;
29671
6/6
✓ Branch 0 taken 12890 times.
✓ Branch 1 taken 5304 times.
✓ Branch 2 taken 18190 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 18190 times.
18194 selectNextBTNWpn(type, game->bwpn, Bwpn, directItemB, COND_AWPN, COND_XWPN, COND_YWPN);
29672 18194 }
29673
29674 void selectNextXWpn(int32_t type)
29675 {
29676 if(!get_qr(qr_SET_XBUTTON_ITEMS)) return;
29677 if(!new_subscreen_active)
29678 return;
29679 selectNextBTNWpn(type, game->xwpn, Xwpn, directItemX, COND_BWPN, COND_AWPN, COND_YWPN);
29680 }
29681
29682 void selectNextYWpn(int32_t type)
29683 {
29684 if(!get_qr(qr_SET_YBUTTON_ITEMS)) return;
29685 if(!new_subscreen_active)
29686 return;
29687 selectNextBTNWpn(type, game->ywpn, Ywpn, directItemY, COND_BWPN, COND_XWPN, COND_AWPN);
29688 }
29689
29690 //helper function
29691 31016119 static void verifyWpn(word& wpos, int32_t& BTNwpn, int32_t& directItemBTN, word f1 = 255, word f2 = 255, word f3 = 255)
29692 {
29693
2/2
✓ Branch 0 taken 31008761 times.
✓ Branch 1 taken 7358 times.
31016119 if(!new_subscreen_active)
29694 7358 return;
29695 31008761 byte pgn = wpos&0xFF, pos = wpos>>8;
29696 31008761 bool empty = pgn==255;
29697
4/4
✓ Branch 0 taken 2443928 times.
✓ Branch 1 taken 28564833 times.
✓ Branch 2 taken 907838 times.
✓ Branch 3 taken 1536090 times.
31008761 if(empty && get_qr(qr_NO_BUTTON_VERIFY)) return; //intentional nothingness
29698
2/2
✓ Branch 0 taken 907838 times.
✓ Branch 1 taken 28564833 times.
29472671 SubscrPage* pg = new_subscreen_active->get_page(pgn==255?new_subscreen_active->curpage:pgn);
29699
1/2
✓ Branch 0 taken 29472671 times.
✗ Branch 1 not taken.
29472671 if(!pg)
29700 return;
29701
5/6
✓ Branch 0 taken 22338197 times.
✓ Branch 1 taken 7134474 times.
✓ Branch 2 taken 7076708 times.
✓ Branch 3 taken 57766 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7076708 times.
29472671 auto fp1 = ((f1&0xFF)==255) ? 255 : ((empty || (f1&0xFF)==(wpos&0xFF)) ? f1 : 255);
29702
5/6
✓ Branch 0 taken 24050342 times.
✓ Branch 1 taken 5422329 times.
✓ Branch 2 taken 5422289 times.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5422289 times.
29472671 auto fp2 = ((f2&0xFF)==255) ? 255 : ((empty || (f2&0xFF)==(wpos&0xFF)) ? f2 : 255);
29703
5/6
✓ Branch 0 taken 24853643 times.
✓ Branch 1 taken 4619028 times.
✓ Branch 2 taken 4618990 times.
✓ Branch 3 taken 38 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4618990 times.
29472671 auto fp3 = ((f3&0xFF)==255) ? 255 : ((empty || (f3&0xFF)==(wpos&0xFF)) ? f3 : 255);
29704 29472671 wpos = pg->movepos_legacy(SEL_VERIFY_RIGHT, wpos, fp1, fp2, fp3);
29705
2/2
✓ Branch 0 taken 907769 times.
✓ Branch 1 taken 28564902 times.
29472671 if((wpos&0xFF) == 0xFF)
29706 907769 BTNwpn = -1;
29707 28564902 else BTNwpn = pg->get_item_pos(wpos>>8);
29708
2/2
✓ Branch 0 taken 28302017 times.
✓ Branch 1 taken 1170654 times.
29472671 directItemBTN = NEG_OR_MASK(BTNwpn,0xFFF);
29709 31016119 }
29710
29711 23850466 void verifyAWpn()
29712 {
29713
2/2
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 23849447 times.
23850466 if (game->forced_awpn != -1)
29714 1019 return;
29715
2/2
✓ Branch 0 taken 1419312 times.
✓ Branch 1 taken 22430135 times.
23849447 if(!get_qr(qr_SELECTAWPN))
29716 {
29717 22430135 Awpn = selectSword();
29718 22430135 game->awpn = 255;
29719 22430135 }
29720 else
29721 {
29722
4/4
✓ Branch 0 taken 873802 times.
✓ Branch 1 taken 545510 times.
✓ Branch 2 taken 545510 times.
✓ Branch 3 taken 873802 times.
1419312 verifyWpn(game->awpn, Awpn, directItemA, COND_BWPN, COND_XWPN, COND_YWPN);
29723 }
29724 23850466 }
29725
29726 23844282 void verifyBWpn()
29727 {
29728
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 23843269 times.
23844282 if (game->forced_bwpn != -1)
29729 1013 return;
29730
6/6
✓ Branch 0 taken 1418494 times.
✓ Branch 1 taken 22424775 times.
✓ Branch 2 taken 2876769 times.
✓ Branch 3 taken 20966500 times.
✓ Branch 4 taken 2876769 times.
✓ Branch 5 taken 20966500 times.
23843269 verifyWpn(game->bwpn, Bwpn, directItemB, COND_AWPN, COND_XWPN, COND_YWPN);
29731 23844282 }
29732
29733 23844282 void verifyXWpn()
29734 {
29735
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 23843269 times.
23844282 if (game->forced_xwpn != -1)
29736 1013 return;
29737
2/2
✓ Branch 0 taken 2876769 times.
✓ Branch 1 taken 20966500 times.
23843269 if(!get_qr(qr_SET_XBUTTON_ITEMS))
29738 20966500 return;
29739
3/4
✓ Branch 0 taken 2331951 times.
✓ Branch 1 taken 544818 times.
✓ Branch 2 taken 2876769 times.
✗ Branch 3 not taken.
2876769 verifyWpn(game->xwpn, Xwpn, directItemX, COND_BWPN, COND_AWPN, COND_YWPN);
29740 23844282 }
29741
29742 23844282 void verifyYWpn()
29743 {
29744
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 23843269 times.
23844282 if (game->forced_ywpn != -1)
29745 1013 return;
29746
2/2
✓ Branch 0 taken 2876769 times.
✓ Branch 1 taken 20966500 times.
23843269 if(!get_qr(qr_SET_YBUTTON_ITEMS))
29747 20966500 return;
29748
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2876769 times.
✓ Branch 2 taken 544818 times.
✓ Branch 3 taken 2331951 times.
2876769 verifyWpn(game->ywpn, Ywpn, directItemY, COND_BWPN, COND_XWPN, COND_AWPN);
29749 23844282 }
29750
29751 23844282 void verifyBothWeapons()
29752 {
29753 23844282 verifyAWpn();
29754 23844282 verifyBWpn();
29755 23844282 verifyXWpn();
29756 23844282 verifyYWpn();
29757 23844282 }
29758
29759 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
29760 22430491 int32_t selectSword()
29761 {
29762 22430491 return current_item_id(itype_sword);
29763 }
29764
29765 // Adding code here for allowing hardcoding a button to a specific itemclass.
29766 int32_t selectItemclass(int32_t itemclass)
29767 {
29768 int32_t ret = current_item_id(itemclass);
29769
29770 if(ret == -1)
29771 ret = 0;
29772
29773 return ret;
29774 }
29775
29776 // Used for the 'Pickup Hearts' item pickup condition.
29777 302 bool canget(int32_t id)
29778 {
29779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 302 times.
302 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
29780 }
29781
29782 63 void dospecialmoney(int32_t index)
29783 {
29784 63 int32_t tmp=currscr>=128?1:0;
29785 63 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
29786
29787
4/7
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
63 switch(tmpscr[tmp].room)
29788 {
29789 case rINFO: // pay for info
29790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
29791 {
29792
29793
29794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!current_item_power(itype_wallet))
29795 {
29796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (game->get_spendable_rupies() < abs(prices[priceindex]))
29797 return;
29798 16 int32_t tmpprice = -abs(prices[priceindex]);
29799 16 int32_t total = game->get_drupy()-tmpprice;
29800 16 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29801 16 game->set_drupy(game->get_drupy()-total);
29802 //game->change_drupy(-abs(prices[priceindex]));
29803 16 }
29804
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( current_item_power(itype_wallet)>0 )
29805 {
29806 game->change_drupy(0);
29807 }
29808 16 }
29809 16 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
29810 16 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
29811 16 donewmsg(QMisc.info[tmpscr[tmp].catchall].str[priceindex]);
29812 16 clear_bitmap(pricesdisplaybuf);
29813 16 set_clip_state(pricesdisplaybuf, 1);
29814 16 items.del(0);
29815
29816
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for(int32_t i=0; i<items.Count(); i++)
29817 48 ((item*)items.spr(i))->pickup=ipDUMMY;
29818
29819 // Prevent the prices from being displayed anymore
29820
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for(int32_t i=0; i<3; i++)
29821 {
29822 48 prices[i] = 0;
29823 48 }
29824
29825 16 break;
29826
29827 case rMONEY: // secret money
29828 {
29829 20 ((item*)items.spr(0))->pickup = ipDUMMY;
29830
29831 20 prices[0] = tmpscr[tmp].catchall;
29832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (!current_item_power(itype_wallet))
29833 20 game->change_drupy(prices[0]);
29834 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
29835
29836 20 putprices(false);
29837
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
20 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29838 20 break;
29839 }
29840
29841 case rGAMBLE: // gamble
29842 {
29843 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
29844
29845 unsigned si=(zc_oldrand()%24)*3;
29846
29847 for(int32_t i=0; i<3; i++)
29848 prices[i]=gambledat[si++];
29849
29850 game->set_drupy(game->get_drupy()+prices[priceindex]);
29851 putprices(true);
29852
29853 for(int32_t i=1; i<4; i++)
29854 ((item*)items.spr(i))->pickup=ipDUMMY;
29855 }
29856 break;
29857
29858 case rBOMBS:
29859 {
29860
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
29861 return;
29862
29863 15 int32_t price = -tmpscr[tmp].catchall;
29864 15 int32_t wmedal = current_item_id(itype_wealthmedal);
29865
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(wmedal >= 0)
29866 {
29867 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
29868 price*=(itemsbuf[wmedal].misc1/100.0);
29869 else
29870 price+=itemsbuf[wmedal].misc1;
29871 }
29872
29873 15 int32_t total = game->get_drupy()-price;
29874 15 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29875 15 game->set_drupy(game->get_drupy()-total);
29876 //game->set_drupy(game->get_drupy()+price);
29877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29878 15 game->change_maxbombs(4);
29879 15 game->set_bombs(game->get_maxbombs());
29880 {
29881 15 int32_t div = zinit.bomb_ratio;
29882
29883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(div > 0)
29884 15 game->change_maxcounter(4/div, 6);
29885 }
29886
29887 //also give Hero an actual Bomb item
29888
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 15 times.
3855 for(int32_t i=0; i<MAXITEMS; i++)
29889 {
29890
4/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 3823 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 15 times.
3840 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
29891 15 getitem(i, true, true);
29892 3840 }
29893
29894 15 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
29895 15 fadeclk=66;
29896 15 dismissmsg();
29897 15 clear_bitmap(pricesdisplaybuf);
29898 15 set_clip_state(pricesdisplaybuf, 1);
29899 15 verifyBothWeapons();
29900 15 break;
29901 }
29902
29903 case rARROWS:
29904 {
29905 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
29906 return;
29907
29908 int32_t price = -tmpscr[tmp].catchall;
29909 int32_t wmedal = current_item_id(itype_wealthmedal);
29910 if(wmedal >= 0)
29911 {
29912 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
29913 price*=(itemsbuf[wmedal].misc1/100.0);
29914 else
29915 price+=itemsbuf[wmedal].misc1;
29916 }
29917
29918 int32_t total = game->get_drupy()-price;
29919 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29920 game->set_drupy(game->get_drupy()-total);
29921
29922 //game->set_drupy(game->get_drupy()+price);
29923 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29924 game->change_maxarrows(10);
29925 game->set_arrows(game->get_maxarrows());
29926 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
29927 fadeclk=66;
29928 dismissmsg();
29929 clear_bitmap(pricesdisplaybuf);
29930 set_clip_state(pricesdisplaybuf, 1);
29931 verifyBothWeapons();
29932 break;
29933 }
29934
29935 case rSWINDLE:
29936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(items.spr(index)->id==iRupy)
29937 {
29938
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
29939 return;
29940 12 int32_t tmpprice = -tmpscr[tmp].catchall;
29941 12 int32_t total = game->get_drupy()-tmpprice;
29942 12 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29943 12 game->set_drupy(game->get_drupy()-total);
29944 12 }
29945 else
29946 {
29947 if(game->get_maxlife()<=game->get_hp_per_heart())
29948 return;
29949
29950 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
29951 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
29952 }
29953
29954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29955 12 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
29956 12 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
29957 12 fadeclk=66;
29958 12 dismissmsg();
29959 12 clear_bitmap(pricesdisplaybuf);
29960 12 set_clip_state(pricesdisplaybuf, 1);
29961 12 break;
29962 }
29963 63 }
29964
29965 21819 void getitem(int32_t id, bool nosound, bool doRunPassive)
29966 {
29967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21819 times.
21819 if(unsigned(id) >= MAXITEMS)
29968 return;
29969
29970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21819 times.
21819 if (replay_is_active())
29971
1/2
✓ Branch 0 taken 21819 times.
✗ Branch 1 not taken.
21819 replay_step_comment(fmt::format("getitem {}", item_string[id]));
29972
29973
2/2
✓ Branch 0 taken 21339 times.
✓ Branch 1 taken 480 times.
21819 if(get_qr(qr_SCC_ITEM_COMBINES_ITEMS))
29974 {
29975 480 int32_t nextitem = -1;
29976 480 do
29977 {
29978 480 nextitem = -1;
29979
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
480 if((itemsbuf[id].flags & ITEM_COMBINE) && game->get_item(id))
29980 // Item upgrade routine.
29981 {
29982
29983 for(int32_t i=0; i<MAXITEMS; i++)
29984 {
29985 // Find the item which is as close to this item's fam_type as possible.
29986 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
29987 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
29988 {
29989 nextitem = i;
29990 }
29991 }
29992
29993 if(nextitem>-1)
29994 {
29995 id = nextitem;
29996 if(!get_qr(qr_ITEMCOMBINE_CONTINUOUS))
29997 break; //no looping
29998 }
29999 }
30000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 } while(nextitem > -1);
30001 480 }
30002
30003 21819 itemdata const& idat = itemsbuf[id&0xFF];
30004
30005 43638 bool equipment = idat.flags &
30006 21819 ((idat.family == itype_triforcepiece) ? ITEM_FLAG8 : ITEM_GAMEDATA);
30007
30008
2/2
✓ Branch 0 taken 19819 times.
✓ Branch 1 taken 2000 times.
21819 if(equipment)
30009 {
30010 // Fix boomerang sounds.
30011 2000 int32_t itemid = current_item_id(idat.family);
30012
30013
4/6
✓ Branch 0 taken 1094 times.
✓ Branch 1 taken 906 times.
✓ Branch 2 taken 1075 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2000 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_divineprotection
30014
5/6
✓ Branch 0 taken 1075 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1073 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1072 times.
✓ Branch 5 taken 1 times.
1075 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
30015 1094 && sfx_allocated(itemsbuf[itemid].usesound)
30016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1094 times.
1094 && idat.usesound != itemsbuf[itemid].usesound)
30017 {
30018 stop_sfx(itemsbuf[itemid].usesound);
30019 cont_sfx(idat.usesound);
30020 }
30021
30022 2000 int32_t curitm = current_item_id(idat.family);
30023
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
2000 if(!get_qr(qr_KEEPOLD_APPLIES_RETROACTIVELY)
30024
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2000 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
30025 || (itemsbuf[curitm].flags & ITEM_KEEPOLD))
30026 {
30027 2000 game->set_item(id,true);
30028 2000 passiveitem_script(id, doRunPassive);
30029 2000 }
30030
30031
2/2
✓ Branch 0 taken 710 times.
✓ Branch 1 taken 1290 times.
2000 if(!(idat.flags & ITEM_KEEPOLD))
30032 {
30033
4/4
✓ Branch 0 taken 1122 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 1087 times.
1290 if(!get_qr(qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
30034 {
30035 203 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
30036 203 }
30037 1290 }
30038
30039 // NES consistency: replace all flying boomerangs with the current boomerang.
30040
2/2
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 54 times.
2000 if(idat.family==itype_brang)
30041
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 54 times.
55 for(int32_t i=0; i<Lwpns.Count(); i++)
30042 {
30043 1 weapon *w = ((weapon*)Lwpns.spr(i));
30044
30045
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->id==wBrang)
30046 {
30047 w->LOADGFX(idat.wpn);
30048 }
30049 55 }
30050 2000 }
30051
30052
2/2
✓ Branch 0 taken 2927 times.
✓ Branch 1 taken 18892 times.
21819 if(idat.count!=-1)
30053 {
30054
2/2
✓ Branch 0 taken 18463 times.
✓ Branch 1 taken 429 times.
18892 if(idat.setmax)
30055 {
30056 // Bomb bags are a special case; they may be set not to increase super bombs
30057
5/6
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 410 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 3 times.
429 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
30058 {
30059 3 int32_t max = game->get_maxbombs();
30060
30061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(max<idat.max) max=idat.max;
30062
30063
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
30064 3 }
30065 else
30066 {
30067 426 int32_t max = game->get_maxcounter(idat.count);
30068
30069
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 344 times.
426 if(max<idat.max) max=idat.max;
30070
30071
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 144 times.
426 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
30072 }
30073 429 }
30074
30075 // Amount is an uint16_t, but the range is -9999 to 16383
30076 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
30077
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 18607 times.
18892 if(idat.amount&0x3FFF)
30078 {
30079
2/2
✓ Branch 0 taken 10743 times.
✓ Branch 1 taken 7864 times.
18607 if(idat.amount&0x8000)
30080 21486 game->set_dcounter(
30081
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10742 times.
10743 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
30082 else
30083 {
30084
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7864 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
30085 game->set_counter(0, idat.count);
30086 else
30087 // This is too confusing to try and change...
30088
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7864 times.
✓ Branch 2 taken 3675 times.
✓ Branch 3 taken 4189 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3675 times.
7864 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
30089 }
30090 18607 }
30091 18892 }
30092
30093
4/4
✓ Branch 0 taken 21784 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 534 times.
✓ Branch 3 taken 21250 times.
21819 if(idat.playsound&&!nosound)
30094 {
30095 21250 sfx(idat.playsound);
30096 21250 }
30097
30098 //add lower-level items
30099
2/2
✓ Branch 0 taken 21769 times.
✓ Branch 1 taken 50 times.
21819 if(idat.flags&ITEM_GAINOLD)
30100 {
30101
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 50 times.
90 for(int32_t i=idat.fam_type-1; i>0; i--)
30102 {
30103 40 int32_t potid = getItemID(itemsbuf, idat.family, i);
30104
30105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(potid != -1)
30106 {
30107 40 game->set_item(potid, true);
30108 40 }
30109 40 }
30110 50 }
30111
30112
12/14
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 20039 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 475 times.
✓ Branch 6 taken 126 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 100 times.
✓ Branch 9 taken 89 times.
✓ Branch 10 taken 72 times.
✓ Branch 11 taken 722 times.
✓ Branch 12 taken 119 times.
✓ Branch 13 taken 24 times.
21819 switch(idat.family)
30113 {
30114 case itype_itmbundle:
30115 {
30116 18 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
30117 15 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
30118 3 bool pscript = (idat.flags & ITEM_FLAG1);
30119
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3 times.
33 for(auto q = 0; q < 10; ++q)
30120 {
30121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(unsigned(ids[q]) >= MAXITEMS) continue;
30122
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 10 times.
30 if(pscript)
30123 10 collectitem_script(ids[q]);
30124 30 getitem(ids[q], true, true);
30125 30 }
30126 }
30127 3 break;
30128
30129 case itype_progressive_itm:
30130 {
30131 int32_t newid = get_progressive_item(idat);
30132 if(newid > -1)
30133 getitem(newid, nosound, true);
30134 }
30135 break;
30136
30137 case itype_bottlefill:
30138 {
30139 if(idat.misc1)
30140 {
30141 game->fillBottle(idat.misc1);
30142 }
30143 }
30144 break;
30145
30146 case itype_clock:
30147 {
30148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if(idat.flags & ITEM_FLAG1) //Active use, not passive
30149 break;
30150
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
475 if((idat.flags & ITEM_FLAG2) && clockclk) //"Can't activate while clock active"
30151 break;
30152 475 setClock(watch=true);
30153
30154
2/2
✓ Branch 0 taken 243200 times.
✓ Branch 1 taken 475 times.
243675 for(int32_t i=0; i<eMAXGUYS; i++)
30155 243200 clock_zoras[i]=0;
30156
30157 475 clockclk=itemsbuf[id&0xFF].misc1;
30158 475 sfx(idat.usesound);
30159 }
30160 475 break;
30161
30162 case itype_lkey:
30163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(game->lvlkeys[dlevel]<255) game->lvlkeys[dlevel]++;
30164 126 break;
30165
30166 case itype_ring:
30167 case itype_magicring:
30168
6/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 2 times.
45 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
30169 {
30170 43 ringcolor(false);
30171 43 }
30172 45 break;
30173
30174 case itype_whispring:
30175 {
30176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(idat.flags & ITEM_FLAG1)
30177 {
30178
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
30179
30180
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
30181 5 }
30182
30183
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if(idat.power==0)
30184 {
30185 2 setSwordClk(0);
30186 2 setItemClk(0);
30187 2 }
30188
30189 5 break;
30190 }
30191
30192
30193 case itype_map:
30194 100 game->lvlitems[dlevel]|=liMAP;
30195 100 break;
30196
30197 case itype_compass:
30198 89 game->lvlitems[dlevel]|=liCOMPASS;
30199 89 break;
30200
30201 case itype_bosskey:
30202 72 game->lvlitems[dlevel]|=liBOSSKEY;
30203 72 break;
30204
30205 case itype_fairy:
30206
30207
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 517 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 205 times.
722 game->set_life(zc_min(game->get_life()+(idat.flags&ITEM_FLAG1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
30208
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 115 times.
✓ Branch 3 taken 607 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 115 times.
722 game->set_magic(zc_min(game->get_magic()+(idat.flags&ITEM_FLAG2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
30209 722 break;
30210
30211 case itype_heartpiece:
30212 119 game->change_HCpieces(1);
30213
30214
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 26 times.
119 if(game->get_HCpieces()<game->get_hcp_per_hc())
30215 93 break;
30216
30217 26 game->set_HCpieces(0);
30218
30219 26 getitem(heart_container_id());
30220 26 break;
30221
30222 case itype_killem:
30223 {
30224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(idat.flags & ITEM_FLAG1) //Active use, not passive
30225 break;
30226 24 kill_em_all();
30227 24 sfx(idat.usesound);
30228 }
30229 24 break;
30230 }
30231
30232 21819 flushItemCache();
30233 21819 update_subscreens();
30234 21819 refresh_subscr_items();
30235 21819 verifyBothWeapons();
30236 21819 }
30237
30238 9 void takeitem(int32_t id)
30239 {
30240 9 game->set_item(id, false);
30241 9 itemdata const& idat = itemsbuf[id];
30242
30243 /* Lower the counters! */
30244
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(idat.count!=-1)
30245 {
30246 if(idat.setmax)
30247 {
30248 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
30249 }
30250
30251 if(idat.amount&0x3FFF)
30252 {
30253 if(idat.amount&0x8000)
30254 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
30255 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
30256 }
30257 }
30258
30259
1/10
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9 switch(itemsbuf[id&0xFF].family)
30260 {
30261 // NES consistency: replace all flying boomerangs with the current boomerang.
30262 case itype_brang:
30263 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
30264 {
30265 weapon *w = ((weapon*)Lwpns.spr(i));
30266
30267 if(w->id==wBrang)
30268 {
30269 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
30270 }
30271 }
30272
30273 break;
30274
30275 case itype_itmbundle:
30276 {
30277 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
30278 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
30279 for(auto q = 0; q < 10; ++q)
30280 {
30281 if(unsigned(ids[q]) >= MAXITEMS) continue;
30282 takeitem(ids[q]);
30283 }
30284 }
30285 break;
30286
30287 case itype_progressive_itm:
30288 {
30289 int32_t newid = get_progressive_item(idat, true);
30290 if(newid > -1)
30291 takeitem(newid);
30292 }
30293 break;
30294
30295 case itype_heartpiece:
30296 if(game->get_maxlife()>game->get_hp_per_heart())
30297 {
30298 if(game->get_HCpieces()==0)
30299 {
30300 game->set_HCpieces(game->get_hcp_per_hc());
30301 takeitem(iHeartC);
30302 }
30303
30304 game->change_HCpieces(-1);
30305 }
30306 break;
30307
30308 case itype_map:
30309 game->lvlitems[dlevel]&=~liMAP;
30310 break;
30311
30312 case itype_compass:
30313 game->lvlitems[dlevel]&=~liCOMPASS;
30314 break;
30315
30316 case itype_bosskey:
30317 game->lvlitems[dlevel]&=~liBOSSKEY;
30318 break;
30319
30320 case itype_lkey:
30321 if(game->lvlkeys[dlevel]) game->lvlkeys[dlevel]--;
30322 break;
30323
30324 case itype_ring:
30325 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
30326 {
30327 ringcolor(false);
30328 }
30329 break;
30330 }
30331 9 }
30332
30333 14127 void post_item_collect()
30334 {
30335 14127 std::vector<int32_t> &ev = FFCore.eventData;
30336 14127 ev.clear();
30337
30338 14127 throwGenScriptEvent(GENSCR_EVENT_POST_COLLECT_ITEM);
30339 14127 }
30340
30341 14344 void HeroClass::handle_triforce(int32_t id)
30342 {
30343
1/2
✓ Branch 0 taken 14344 times.
✗ Branch 1 not taken.
14344 if(unsigned(id) >= MAXITEMS)
30344 return;
30345 14344 itemdata const& itm = itemsbuf[id];
30346
3/3
✓ Branch 0 taken 14226 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 115 times.
14344 switch(itm.family)
30347 {
30348 case itype_itmbundle:
30349 {
30350 18 int ids[10] = {itm.misc1, itm.misc2, itm.misc3, itm.misc4, itm.misc5,
30351 15 itm.misc6, itm.misc7, itm.misc8, itm.misc9, itm.misc10};
30352
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3 times.
33 for(auto q = 0; q < 10; ++q)
30353 {
30354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(unsigned(ids[q]) >= MAXITEMS) continue;
30355 30 handle_triforce(ids[q]);
30356 30 }
30357 }
30358 3 break;
30359 case itype_triforcepiece:
30360 {
30361
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 100 times.
115 if(itm.misc2>0)
30362 100 getTriforce(id); //small
30363 15 else getBigTri(id); //big
30364 }
30365 115 break;
30366 }
30367 14344 }
30368
30369 // Attempt to pick up an item. (-1 = check items touching Hero.)
30370 14141950 void HeroClass::checkitems(int32_t index)
30371 {
30372 14141950 int32_t tmp=currscr>=128?1:0;
30373
30374
2/2
✓ Branch 0 taken 1828 times.
✓ Branch 1 taken 14140122 times.
14141950 if(index==-1)
30375 {
30376
2/2
✓ Branch 0 taken 2986530 times.
✓ Branch 1 taken 14140122 times.
17126652 for(auto ind = items.Count()-1; ind >= 0; --ind)
30377 {
30378 2986530 item* itm = (item*)items.spr(ind);
30379
2/2
✓ Branch 0 taken 2986481 times.
✓ Branch 1 taken 49 times.
2986530 if(itm->get_forcegrab())
30380 {
30381 49 checkitems(ind);
30382 49 }
30383 2986530 }
30384
2/2
✓ Branch 0 taken 4404598 times.
✓ Branch 1 taken 9735524 times.
14140122 if(diagonalMovement)
30385 {
30386 4404598 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
30387 4404598 }
30388 9735524 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
30389 14140122 }
30390
30391
2/2
✓ Branch 0 taken 119655 times.
✓ Branch 1 taken 14022295 times.
14141950 if(index==-1)
30392 14022295 return;
30393
30394 // if (tmpscr[tmp].room==rSHOP && boughtsomething==true)
30395 // return;
30396 119655 item* ptr = (item*)items.spr(index);
30397 119655 int32_t pickup = ptr->pickup;
30398 119655 int8_t exstate = ptr->pickupexstate;
30399 119655 int32_t PriceIndex = ptr->PriceIndex;
30400 119655 int32_t id2 = ptr->id;
30401 119655 int32_t holdid = ptr->id;
30402 119655 int32_t pstr = ptr->pstring;
30403 119655 int32_t pstr_flags = ptr->pickup_string_flags;
30404 119655 int32_t linked_parent = ptr->linked_parent;
30405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119655 times.
119655 if(ptr->fallclk > 0) return; //Don't pick up a falling item
30406
30407
1/2
✓ Branch 0 taken 119655 times.
✗ Branch 1 not taken.
119655 if(itemsbuf[id2].family == itype_progressive_itm)
30408 {
30409 int32_t newid = get_progressive_item(itemsbuf[id2]);
30410 if(newid > -1)
30411 {
30412 id2 = newid;
30413 holdid = newid;
30414 pstr = itemsbuf[newid].pstring;
30415 pstr_flags = itemsbuf[newid].pickup_string_flags;
30416 }
30417 }
30418
30419
2/2
✓ Branch 0 taken 118631 times.
✓ Branch 1 taken 1024 times.
119655 bool bottledummy = (pickup&ipCHECK) && tmpscr[tmp].room == rBOTTLESHOP;
30420
30421
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 119630 times.
119655 if(bottledummy) //Dummy bullshit!
30422 {
30423
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!game->canFillBottle())
30424 return;
30425
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
30426 {
30427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!current_item_power(itype_wallet))
30428 {
30429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
30430 1 int32_t tmpprice = -abs(prices[PriceIndex]);
30431 //game->change_drupy(-abs(prices[priceindex]));
30432 1 int32_t total = game->get_drupy()-tmpprice;
30433 1 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
30434 1 game->set_drupy(game->get_drupy()-total);
30435 1 }
30436 else //infinite wallet
30437 {
30438 game->change_drupy(0);
30439 }
30440 1 }
30441 25 boughtsomething=true;
30442 //make the other shop items untouchable after
30443 //you buy something
30444
30445
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 25 times.
29 for(int32_t i=0; i<items.Count(); i++)
30446 {
30447
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
4 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
30448 2 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
30449 4 }
30450
30451 25 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[PriceIndex]);
30452 25 id2 = find_bottle_for_slot(slot);
30453 25 ptr->id = id2;
30454 25 holdid = id2;
30455 25 pstr = 0;
30456 25 pickup |= ipHOLDUP;
30457 25 }
30458 else
30459 {
30460
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119630 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119630 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
30461 return; //No picking these up unless you have a bottle to fill!
30462
30463
5/6
✓ Branch 0 taken 114421 times.
✓ Branch 1 taken 5209 times.
✓ Branch 2 taken 103063 times.
✓ Branch 3 taken 11358 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 103063 times.
119630 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
30464
2/2
✓ Branch 0 taken 102858 times.
✓ Branch 1 taken 205 times.
103063 if(ptr->id!=iFairyMoving)
30465 // wait for it to stop flashing, doesn't check for other items yet
30466 102858 return;
30467
30468
2/2
✓ Branch 0 taken 16717 times.
✓ Branch 1 taken 55 times.
16772 if(pickup&ipENEMY) // item was being carried by enemy
30469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
110 if(more_carried_items()<=1) // 1 includes this own item.
30470 55 hasitem &= ~2;
30471
30472
2/2
✓ Branch 0 taken 1703 times.
✓ Branch 1 taken 15069 times.
16772 if(pickup&ipDUMMY) // dummy item (usually a rupee)
30473 {
30474
2/2
✓ Branch 0 taken 1640 times.
✓ Branch 1 taken 63 times.
1703 if(pickup&ipMONEY)
30475 63 dospecialmoney(index);
30476
30477 1703 return;
30478 }
30479
30480
3/4
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 14974 times.
✓ Branch 2 taken 95 times.
✗ Branch 3 not taken.
15069 if(get_qr(qr_HEARTSREQUIREDFIX) && !canget(id2))
30481 return;
30482
30483 15069 int32_t nextitem = -1;
30484 15069 do
30485 {
30486 15069 nextitem = -1;
30487
4/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 15044 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 14 times.
15069 if((itemsbuf[id2].flags & ITEM_COMBINE) && game->get_item(id2))
30488 // Item upgrade routine.
30489 {
30490
30491
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 14 times.
3598 for(int32_t i=0; i<MAXITEMS; i++)
30492 {
30493 // Find the item which is as close to this item's fam_type as possible.
30494
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 3553 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 14 times.
3584 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
30495
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
31 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
30496 {
30497 14 nextitem = i;
30498 14 }
30499 3584 }
30500
30501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(nextitem>-1)
30502 {
30503 14 id2 = nextitem;
30504
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(get_qr(qr_ITEMCOMBINE_NEW_PSTR))
30505 {
30506 pstr = itemsbuf[id2].pstring;
30507 pstr_flags = itemsbuf[id2].pickup_string_flags;
30508 }
30509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!get_qr(qr_ITEMCOMBINE_CONTINUOUS))
30510 14 break; //no looping
30511 }
30512 }
30513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15055 times.
15055 } while(nextitem > -1);
30514
30515
2/2
✓ Branch 0 taken 14046 times.
✓ Branch 1 taken 1023 times.
15069 if(pickup&ipCHECK) // check restrictions
30516
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 709 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 107 times.
1023 switch(tmpscr[tmp].room)
30517 {
30518 case rSP_ITEM: // special item
30519
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 63 times.
207 if(!canget(id2)) // These ones always need the Hearts Required check
30520 63 return;
30521
30522 144 break;
30523
30524 case rP_SHOP: // potion shop
30525
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 14 times.
107 if(msg_active)
30526 93 return;
30527 [[fallthrough]];
30528 case rSHOP: // shop
30529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 723 times.
723 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
30530 {
30531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 723 times.
723 if(!current_item_power(itype_wallet))
30532 {
30533
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 123 times.
723 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
30534 123 int32_t tmpprice = -abs(prices[PriceIndex]);
30535 //game->change_drupy(-abs(prices[priceindex]));
30536 123 int32_t total = game->get_drupy()-tmpprice;
30537 123 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
30538 123 game->set_drupy(game->get_drupy()-total);
30539 123 }
30540 else //infinite wallet
30541 {
30542 game->change_drupy(0);
30543 }
30544 123 }
30545 123 boughtsomething=true;
30546 //make the other shop items untouchable after
30547 //you buy something
30548 123 int32_t count = 0;
30549
30550
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 123 times.
492 for(int32_t i=0; i<3; i++)
30551 {
30552
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 324 times.
369 if(QMisc.shop[tmpscr[tmp].catchall].hasitem[i] != 0)
30553 {
30554 324 ++count;
30555 324 }
30556 369 }
30557
30558
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 123 times.
573 for(int32_t i=0; i<items.Count(); i++)
30559 {
30560
4/4
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 123 times.
✓ Branch 3 taken 201 times.
450 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
30561 201 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
30562 450 }
30563
30564 123 break;
30565 267 }
30566
30567 //EVENT
30568 {
30569 14313 std::vector<int32_t> &ev = FFCore.eventData;
30570 14313 ev.clear();
30571 14313 ev.push_back(id2*10000);
30572 14313 ev.push_back(pickup*10000);
30573 14313 ev.push_back(pstr*10000);
30574 14313 ev.push_back(pstr_flags*10000);
30575 14313 ev.push_back(0);
30576 14313 ev.push_back(ptr->getUID());
30577 14313 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
30578 14313 ev.push_back(0);
30579
30580 14313 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
30581 14313 bool nullify = ev[4] != 0;
30582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14313 times.
14313 if(nullify) return;
30583 14313 id2 = ev[0]/10000;
30584 14313 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
30585 14313 pstr = ev[2] / 10000;
30586 14313 pstr_flags = ev[3] / 10000;
30587 }
30588
30589
2/2
✓ Branch 0 taken 1527 times.
✓ Branch 1 taken 12786 times.
14313 if(pickup&ipONETIME) // set mITEM for one-time-only items
30590 {
30591 1527 setmapflag(mITEM);
30592
30593 //Okay so having old source files is a godsend. You wanna know why?
30594 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
30595 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
30596 //The default would be mITEM if currscr was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
30597 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
30598 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
30599
30600 /*
30601 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
30602 // broken behavior from early ZC versions. If you change things here please comment on its purpose.
30603
30604 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
30605 // What is etc?! We need to check for every valid state here. ~Gleeok
30606 if(get_qr(qr_ITEMPICKUPSETSBELOW))
30607 {
30608 // Most older quests need one-time-pickups to not remove special items, etc.
30609 if(tmpscr->room==rGRUMBLE)
30610 {
30611 setmapflag(mSPECIALITEM);
30612 }
30613 }
30614 */
30615 1527 }
30616
2/2
✓ Branch 0 taken 12024 times.
✓ Branch 1 taken 762 times.
12786 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
30617
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 501 times.
762 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
30618
30619
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
14313 if(exstate > -1 && exstate < 32)
30620 {
30621 1 setxmapflag(1<<exstate);
30622 1 }
30623
30624
2/2
✓ Branch 0 taken 14312 times.
✓ Branch 1 taken 1 times.
14313 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
30625 {
30626
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
30627 1 hidden_entrance(0, true, false, -5);
30628 1 }
30629
30630 14313 collectitem_script(id2);
30631 14313 getitem(id2, ptr->noSound, true);
30632 }
30633
30634
2/2
✓ Branch 0 taken 1526 times.
✓ Branch 1 taken 12812 times.
14338 if(pickup&ipHOLDUP)
30635 {
30636 1526 attackclk=0;
30637 1526 reset_swordcharge();
30638
30639
3/4
✓ Branch 0 taken 1485 times.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1485 times.
1526 if(action!=swimming && !IsSideSwim())
30640 1485 reset_hookshot();
30641
30642
2/2
✓ Branch 0 taken 1181 times.
✓ Branch 1 taken 279 times.
1526 if(msg_onscreen)
30643 {
30644 279 dismissmsg();
30645 279 }
30646
30647 1460 clear_bitmap(pricesdisplaybuf);
30648
30649
7/8
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 1316 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 68 times.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 69 times.
✓ Branch 7 taken 117 times.
1494 if(get_qr(qr_OLDPICKUP) || ((tmpscr[tmp].room==rSP_ITEM || tmpscr[tmp].room==rRP_HC || tmpscr[tmp].room==rTAKEONE) && (pickup&ipONETIME2)) ||
30650
4/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
117 (get_qr(qr_SHOP_ITEMS_VANISH) && (tmpscr[tmp].room==rBOTTLESHOP || tmpscr[tmp].room==rSHOP) && (pickup&ipCHECK)))
30651 {
30652 1419 fadeclk=66;
30653 1419 }
30654
30655
5/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 1480 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 12 times.
1502 if(id2!=iBombs || action==swimming || get_qr(qr_BOMBHOLDFIX))
30656 {
30657 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
30658
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1473 times.
1490 if(action==swimming)
30659 {
30660 17 action=waterhold1; FFCore.setHeroAction(waterhold1);
30661 17 }
30662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1473 times.
1473 else if(IsSideSwim())
30663 {
30664 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
30665 }
30666 else
30667 {
30668 1473 action=landhold1; FFCore.setHeroAction(landhold1);
30669 }
30670
30671
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 348 times.
1490 if(ptr->twohand)
30672 {
30673
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 342 times.
348 if(action==waterhold1)
30674 {
30675 6 action=waterhold2; FFCore.setHeroAction(waterhold2);
30676 6 }
30677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
342 else if(action==sidewaterhold1)
30678 {
30679 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
30680 }
30681 else
30682 {
30683 342 action=landhold2; FFCore.setHeroAction(landhold2);
30684 }
30685 348 }
30686
30687 1490 holdclk=130;
30688
30689 //restart music
30690
2/2
✓ Branch 0 taken 1381 times.
✓ Branch 1 taken 109 times.
1490 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0)
30691 109 music_stop();
30692
30693 1490 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
30694 1490 freeze_guys=true;
30695 //show the info string
30696
30697
30698 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
30699
30700 1490 int32_t shop_pstr = 0;
30701
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 1348 times.
1490 if (PriceIndex > -1)
30702 {
30703
3/3
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 109 times.
✓ Branch 2 taken 1 times.
142 switch(tmpscr[tmp].room)
30704 {
30705 case rSHOP:
30706 109 shop_pstr = QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex];
30707 109 break;
30708 case rBOTTLESHOP:
30709 1 shop_pstr = QMisc.bottle_shop_types[tmpscr[tmp].catchall].str[PriceIndex];
30710 1 break;
30711 }
30712 142 }
30713
5/6
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1471 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1470 times.
1490 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
30714 {
30715
9/12
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 14 times.
20 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
30716 {
30717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
30718 19 }
30719 1 else pstr = 0;
30720
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 19 times.
20 if(shop_pstr)
30721 {
30722 1 donewmsg(shop_pstr);
30723 1 enqueued_str = pstr;
30724 1 }
30725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 else if(pstr)
30726 {
30727 19 donewmsg(pstr);
30728 19 }
30729 20 }
30730
30731 1490 }
30732
30733
4/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1398 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 4 times.
1502 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & ITEM_GAMEDATA))
30734 {
30735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1402 times.
1402 if (!ptr->noHoldSound) sfx(tmpscr[0].holdupsfx);
30736 1402 }
30737
30738 1502 ptr->set_forcegrab(false);
30739 1502 items.del(index);
30740
30741
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 1502 times.
1718 for(int32_t i=0; i<Lwpns.Count(); i++)
30742 {
30743 216 weapon *w = (weapon*)Lwpns.spr(i);
30744
30745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(w->dragging==index)
30746 {
30747 w->dragging=-1;
30748 }
30749
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 else if(w->dragging>index)
30750 {
30751 w->dragging-=1;
30752 }
30753 216 }
30754
30755 // clear up shop stuff
30756
4/4
✓ Branch 0 taken 813 times.
✓ Branch 1 taken 689 times.
✓ Branch 2 taken 690 times.
✓ Branch 3 taken 123 times.
1502 if((isdungeon()==0)&&(index!=0))
30757 {
30758
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 83 times.
123 if(boughtsomething)
30759 {
30760 83 fadeclk=66;
30761
30762
3/4
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
83 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
30763 {
30764 80 items.del(0);
30765
30766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 for(int32_t i=0; i<Lwpns.Count(); i++)
30767 {
30768 weapon *w = (weapon*)Lwpns.spr(i);
30769
30770 if(w->dragging==0)
30771 {
30772 w->dragging=-1;
30773 }
30774 else if(w->dragging>0)
30775 {
30776 w->dragging-=1;
30777 }
30778 }
30779 80 }
30780 83 }
30781
30782
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(msg_onscreen)
30783 {
30784 dismissmsg();
30785 }
30786
30787 123 clear_bitmap(pricesdisplaybuf);
30788 123 set_clip_state(pricesdisplaybuf, 1);
30789 123 }
30790
30791 // items.del(index);
30792 1502 }
30793 else
30794 {
30795 12812 ptr->set_forcegrab(false);
30796 12812 items.del(index);
30797
30798
2/2
✓ Branch 0 taken 9164 times.
✓ Branch 1 taken 12812 times.
21976 for(int32_t i=0; i<Lwpns.Count(); i++)
30799 {
30800 9164 weapon *w = (weapon*)Lwpns.spr(i);
30801
30802
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 8674 times.
9164 if(w->dragging==index)
30803 {
30804 490 w->dragging=-1;
30805 490 }
30806
2/2
✓ Branch 0 taken 8670 times.
✓ Branch 1 taken 4 times.
8674 else if(w->dragging>index)
30807 {
30808 4 w->dragging-=1;
30809 4 }
30810 9164 }
30811
30812
2/2
✓ Branch 0 taken 12799 times.
✓ Branch 1 taken 13 times.
12812 if(msg_onscreen)
30813 {
30814 13 dismissmsg();
30815 13 }
30816
30817 //general item pickup message
30818 //show the info string
30819 //non-held
30820 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
30821
3/6
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 12676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12812 int32_t shop_pstr = ( tmpscr[tmp].room == rSHOP && PriceIndex>=0 && QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] > 0 ) ? QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] : 0;
30822
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12810 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12810 times.
12812 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
30823 {
30824
7/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
2 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
30825 {
30826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
30827 1 }
30828 1 else pstr = 0;
30829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(shop_pstr)
30830 {
30831 donewmsg(shop_pstr);
30832 enqueued_str = pstr;
30833 }
30834
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 else if(pstr)
30835 {
30836 1 donewmsg(pstr);
30837 1 }
30838 2 }
30839
30840
30841 12812 clear_bitmap(pricesdisplaybuf);
30842 12812 set_clip_state(pricesdisplaybuf, 1);
30843 }
30844
30845
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11 times.
14329 if(itemsbuf[id2].family==itype_triforcepiece
30846
4/4
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 14199 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 100 times.
14314 && itemsbuf[id2].misc2 <= 0 && linked_parent == eeGANON)
30847 {
30848 11 game->lvlitems[dlevel]|=liBOSS;
30849 11 }
30850 14314 handle_triforce(id2);
30851
2/2
✓ Branch 0 taken 1415 times.
✓ Branch 1 taken 12899 times.
14314 if(!holdclk)
30852 12899 post_item_collect();
30853 14141926 }
30854
30855 294 void HeroClass::StartRefill(int32_t refillWhat)
30856 {
30857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 if(!refilling)
30858 {
30859 294 refillclk=21;
30860 294 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
30861 294 sfx(WAV_REFILL,128,true);
30862 294 refilling=refillWhat;
30863
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 18 times.
294 if(FFCore.quest_format[vZelda] < 0x255)
30864 {
30865 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
30866 //I attempted to change this check to a quest rule, but here's the issue: this affects
30867 //triforces and potions as well, not just fairy flags. This means that having a compat rule
30868 //would result in a rule that is checked by default for every tileset or quest made before
30869 //2.55, one in a place most people won't check. That means that if they were to go to use
30870 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
30871 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
30872 //"go through the compat rules and turn them all off", so this remains a version check instead
30873 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
30874 276 Start250Refill(refillWhat);
30875 276 }
30876 else //use 2.55+ behavior
30877 {
30878
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if(refill_why>=0) // Item index
30879 {
30880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].family==itype_potion)
30881 {
30882 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
30883 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
30884 }
30885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(itemsbuf[refill_why].family==itype_triforcepiece)
30886 {
30887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
30888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
30889 9 }
30890 9 }
30891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(refill_why==REFILL_FAIRY)
30892 {
30893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!get_qr(qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
30894
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
9 if(get_qr(qr_ITEMBUBBLE))itemclk=0;
30895 9 }
30896 }
30897 294 }
30898 294 }
30899
30900 276 void HeroClass::Start250Refill(int32_t refillWhat)
30901 {
30902
1/2
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
276 if(!refilling)
30903 {
30904 refillclk=21;
30905 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
30906 sfx(WAV_REFILL,128,true);
30907 refilling=refillWhat;
30908
30909 if(refill_why>=0) // Item index
30910 {
30911 if((itemsbuf[refill_why].family==itype_potion)&&(!get_qr(qr_NONBUBBLEMEDICINE)))
30912 {
30913 swordclk=0;
30914 verifyAWpn();
30915 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
30916 }
30917
30918 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_qr(qr_NONBUBBLETRIFORCE)))
30919 {
30920 swordclk=0;
30921 verifyAWpn();
30922 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
30923 }
30924 }
30925 else if((refill_why==REFILL_FAIRY)&&(!get_qr(qr_NONBUBBLEFAIRIES)))
30926 {
30927 swordclk=0;
30928 verifyAWpn();
30929 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
30930 }
30931 }
30932 276 }
30933
30934 375620 bool HeroClass::refill()
30935 {
30936
4/4
✓ Branch 0 taken 22058 times.
✓ Branch 1 taken 353562 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 21422 times.
375620 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
30937 {
30938 354198 return false;
30939 }
30940
30941 21422 ++refillclk;
30942 21422 int32_t speed = get_qr(qr_FASTFILL) ? 6 : 22;
30943 21422 int32_t refill_heart_stop=game->get_maxlife();
30944 21422 int32_t refill_magic_stop=game->get_maxmagic();
30945
30946
4/4
✓ Branch 0 taken 10865 times.
✓ Branch 1 taken 10557 times.
✓ Branch 2 taken 4542 times.
✓ Branch 3 taken 6323 times.
21422 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
30947 {
30948
2/6
✓ Branch 0 taken 6323 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6323 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6323 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & ITEM_FLAG1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
30949
2/6
✓ Branch 0 taken 6323 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6323 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6323 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & ITEM_FLAG2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
30950 6323 }
30951
30952
2/2
✓ Branch 0 taken 18948 times.
✓ Branch 1 taken 2474 times.
21422 if(refillclk%speed == 0)
30953 {
30954 // game->life&=0xFFC;
30955
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1194 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1277 times.
2474 switch(refill_what)
30956 {
30957 case REFILL_LIFE:
30958
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 1139 times.
1194 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
30959
30960
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 1038 times.
1194 if(game->get_life()>=refill_heart_stop)
30961 {
30962 156 game->set_life(refill_heart_stop);
30963 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
30964
2/2
✓ Branch 0 taken 39936 times.
✓ Branch 1 taken 156 times.
40092 for ( int32_t q = 0; q < WAV_COUNT; q++ )
30965 {
30966
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 39780 times.
39936 if ( q == (int32_t)tmpscr->oceansfx ) continue;
30967
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 39779 times.
39780 if ( q == (int32_t)tmpscr->bosssfx ) continue;
30968 39779 stop_sfx(q);
30969 39779 }
30970 156 sfx(QMisc.miscsfx[sfxREFILL]);
30971 156 refilling=REFILL_NONE;
30972 156 return false;
30973 }
30974
30975 1038 break;
30976
30977 case REFILL_MAGIC:
30978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
30979
30980
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(game->get_magic()>=refill_magic_stop)
30981 {
30982 1 game->set_magic(refill_magic_stop);
30983 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
30984
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for ( int32_t q = 0; q < WAV_COUNT; q++ )
30985 {
30986
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 255 times.
256 if ( q == (int32_t)tmpscr->oceansfx ) continue;
30987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 if ( q == (int32_t)tmpscr->bosssfx ) continue;
30988 255 stop_sfx(q);
30989 255 }
30990 1 sfx(QMisc.miscsfx[sfxREFILL]);
30991 1 refilling=REFILL_NONE;
30992 1 return false;
30993 }
30994
30995 2 break;
30996
30997 case REFILL_ALL:
30998
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 1181 times.
1277 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
30999
2/2
✓ Branch 0 taken 1187 times.
✓ Branch 1 taken 90 times.
1277 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
31000
31001
4/4
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 1119 times.
✓ Branch 2 taken 137 times.
✓ Branch 3 taken 21 times.
1277 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
31002 {
31003 137 game->set_life(refill_heart_stop);
31004 137 game->set_magic(refill_magic_stop);
31005 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
31006
2/2
✓ Branch 0 taken 35072 times.
✓ Branch 1 taken 137 times.
35209 for ( int32_t q = 0; q < WAV_COUNT; q++ )
31007 {
31008
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 34935 times.
35072 if ( q == (int32_t)tmpscr->oceansfx ) continue;
31009
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 34915 times.
34935 if ( q == (int32_t)tmpscr->bosssfx ) continue;
31010 34915 stop_sfx(q);
31011 34915 }
31012 137 sfx(QMisc.miscsfx[sfxREFILL]);
31013 137 refilling=REFILL_NONE;
31014 137 return false;
31015 }
31016
31017 1140 break;
31018 }
31019 2180 }
31020
31021 21128 return true;
31022 375620 }
31023
31024 100 void HeroClass::getTriforce(int32_t id2)
31025 {
31026
31027 PALETTE flash_pal;
31028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
31029
31030
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 100 times.
25700 for(int32_t i=0; i<256; i++)
31031 {
31032
2/2
✓ Branch 0 taken 15616 times.
✓ Branch 1 taken 9984 times.
25600 flash_pal[i] = get_qr(qr_FADE) ? _RGB(63,63,0) : _RGB(63,63,63);
31033 25600 }
31034
31035
31036
31037 //get rid off all sprites but Hero
31038 100 guys.clear();
31039 100 items.clear();
31040 100 Ewpns.clear();
31041 100 Lwpns.clear();
31042 100 chainlinks.clear();
31043
31044 100 kill_subscr_items();
31045
31046 //decorations.clear();
31047
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 36 times.
100 if(!COOLSCROLL)
31048 {
31049 36 show_subscreen_items=false;
31050 36 }
31051
31052 100 sfx(itemsbuf[id2].playsound);
31053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) music_stop();
31054
31055 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
31056
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if ( (itemsbuf[id2].flags & ITEM_FLAG14) )
31057 {
31058 uint8_t playwav = itemsbuf[id2].misc3;
31059 //zprint2("playwav is: %d\n", playwav);
31060 sfx(playwav);
31061
31062 }
31063
31064 //itemsbuf[id2].flags & ITEM_FLAG9 : Don't dismiss Messages
31065 //itemsbuf[id2].flags & ITEM_FLAG10 : Cutscene interrupts action script..
31066 //itemsbuf[id2].flags & ITEM_FLAG11 : Don't change music.
31067 //itemsbuf[id2].flags & ITEM_FLAG12 : Run Collect Script Script On Collection
31068 //itemsbuf[id2].flags & ITEM_FLAG13 : Run Action Script On Collection
31069 //itemsbuf[id2].flags & ITEM_FLAG14 : Play second sound (WAV) from Attributes[2] (misc2)
31070 //itemsbuf[id2].flags & ITEM_FLAG15 : No MIDI
31071
31072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!(itemsbuf[id2].flags & ITEM_FLAG15)) //No MIDI flag
31073 {
31074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(itemsbuf[id2].misc1)
31075 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
31076 else
31077 100 try_zcmusic("zelda.nsf",qstpath,moduledata.tf_track,ZC_MIDI_TRIFORCE,get_emusic_volume());
31078 100 }
31079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
31080 {
31081 100 game->lvlitems[dlevel]|=liTRIFORCE;
31082 100 }
31083
31084 100 int32_t f=0;
31085 100 int32_t x2=0;
31086 100 int32_t curtain_x=0;
31087 100 int32_t c=0;
31088
31089 100 do
31090 {
31091
31092
31093
1/2
✓ Branch 0 taken 52360 times.
✗ Branch 1 not taken.
52360 if ( (itemsbuf[id2].flags & ITEM_FLAG13) ) //Run action script on collection.
31094 {
31095 if ( itemsbuf[id2].script )
31096 {
31097 if ( !FFCore.doscript(ScriptType::Item, id2) )
31098 {
31099 int i = id2;
31100 FFCore.reset_script_engine_data(ScriptType::Item, i);
31101 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id2].script, i);
31102 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
31103 }
31104 else
31105 {
31106 if ( !(itemsbuf[id2].flags & ITEM_FLAG10) ) //Cutscene halts the script it resumes after cutscene.
31107 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
31108 }
31109 }
31110 }
31111 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
31112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //No cutscene
31113 {
31114 return;
31115 }
31116
2/2
✓ Branch 0 taken 52260 times.
✓ Branch 1 taken 100 times.
52360 if(f==40)
31117 {
31118 100 actiontype oldaction = action;
31119 100 ALLOFF((!(itemsbuf[id2].flags & ITEM_FLAG9)), false);
31120 100 action=oldaction; // have to reset this flag
31121 100 FFCore.setHeroAction(oldaction);
31122 100 }
31123
31124
31125
4/4
✓ Branch 0 taken 48360 times.
✓ Branch 1 taken 4000 times.
✓ Branch 2 taken 43560 times.
✓ Branch 3 taken 4800 times.
52360 if(f>=40 && f<88)
31126 {
31127
2/2
✓ Branch 0 taken 2928 times.
✓ Branch 1 taken 1872 times.
4800 if(get_qr(qr_FADE))
31128 {
31129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2928 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2928 if (!flash_reduction_enabled() && (f&7) == 0)
31130 {
31131 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
31132 refreshpal=true;
31133 }
31134
31135
2/2
✓ Branch 0 taken 2196 times.
✓ Branch 1 taken 732 times.
2928 if((f&3)==2)
31136 {
31137 732 loadpalset(0,0);
31138 732 loadpalset(1,1);
31139 732 loadpalset(5,5);
31140
31141
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 12 times.
732 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
31142 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
31143 732 }
31144 2928 }
31145 else
31146 {
31147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1872 if(!flash_reduction_enabled() && (f&7) == 0)
31148 {
31149 for(int32_t cs2=2; cs2<5; cs2++)
31150 {
31151 for(int32_t i=1; i<16; i++)
31152 {
31153 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
31154 }
31155 }
31156
31157 refreshpal=true;
31158 }
31159
31160
2/2
✓ Branch 0 taken 1638 times.
✓ Branch 1 taken 234 times.
1872 if((f&7)==4)
31161 {
31162
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
31163 else loadlvlpal(0xB);
31164
31165 234 loadpalset(5,5);
31166 234 }
31167 }
31168 4800 }
31169
31170
31171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
31172 {
31173
2/2
✓ Branch 0 taken 52260 times.
✓ Branch 1 taken 100 times.
52360 if(f==refill_frame)
31174 {
31175 100 refill_what=REFILL_ALL;
31176 100 refill_why=id2;
31177 100 StartRefill(REFILL_ALL);
31178 100 refill();
31179 100 }
31180
31181
2/2
✓ Branch 0 taken 47900 times.
✓ Branch 1 taken 4460 times.
52360 if(f==(refill_frame+1))
31182 {
31183
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 4360 times.
4460 if(refill())
31184 {
31185 4360 --f;
31186 4360 }
31187 4460 }
31188 52360 }
31189
31190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 if(itemsbuf[id2].flags & ITEM_FLAG1) // Warp out flag
31191 {
31192
4/4
✓ Branch 0 taken 27200 times.
✓ Branch 1 taken 25160 times.
✓ Branch 2 taken 19200 times.
✓ Branch 3 taken 8000 times.
52360 if(f>=208 && f<288)
31193 {
31194 8000 ++x2;
31195
31196
3/3
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 3200 times.
✓ Branch 2 taken 1600 times.
8000 switch(++c)
31197 {
31198 case 5:
31199 1600 c=0;
31200 [[fallthrough]];
31201 case 0:
31202 case 2:
31203 case 3:
31204 4800 ++x2;
31205 4800 break;
31206 }
31207 8000 }
31208
31209 52360 do_dcounters();
31210
31211
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 33160 times.
52360 if(f<288)
31212 {
31213 33160 curtain_x=x2&0xF8;
31214 33160 draw_screen_clip_rect_x1=curtain_x;
31215 33160 draw_screen_clip_rect_x2=255-curtain_x;
31216 33160 draw_screen_clip_rect_y1=0;
31217 33160 draw_screen_clip_rect_y2=223;
31218 //draw_screen(tmpscr);
31219 33160 }
31220 52360 }
31221
31222 52360 draw_screen(tmpscr);
31223 //this causes bugs
31224 //the subscreen appearing over the curtain effect should now be fixed in draw_screen
31225 //so this is not necessary -DD
31226 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,false);
31227
31228 //Run Triforce Script
31229 52360 advanceframe(true);
31230 52360 ++f;
31231
2/2
✓ Branch 0 taken 52260 times.
✓ Branch 1 taken 100 times.
104720 }
31232 while
31233 (
31234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
31235
4/6
✓ Branch 0 taken 7300 times.
✓ Branch 1 taken 45060 times.
✓ Branch 2 taken 7300 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7300 times.
52360 || (!(itemsbuf[id2].flags & ITEM_FLAG15) /*&& !(itemsbuf[id2].flags & ITEM_FLAG11)*/ && (midi_pos > 0 && !replay_is_active()))
31236
2/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 7300 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7300 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14600 || (/*!(itemsbuf[id2].flags & ITEM_FLAG15) &&*/ !(itemsbuf[id2].flags & ITEM_FLAG11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
31237 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
31238 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
31239 // value doesn't matter.
31240
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7300 times.
7300 || (replay_is_active() && f < 480) )
31241 ); // 800 may not be just right, but it works
31242
31243 100 action=none; FFCore.setHeroAction(none);
31244 100 holdclk=0;
31245 100 draw_screen_clip_rect_x1=0;
31246 100 draw_screen_clip_rect_x2=255;
31247 100 draw_screen_clip_rect_y1=0;
31248 100 draw_screen_clip_rect_y2=223;
31249 100 show_subscreen_items=true;
31250
31251 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
31252 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
31253
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 1 times.
100 if((itemsbuf[id2].flags & ITEM_FLAG1) && ( get_qr(qr_SIDEVIEWTRIFORCECELLAR) ? ( currscr < MAPSCRS192b136 ) : (currscr < MAPSCRSNORMAL) ) )
31254 {
31255 99 sdir=dir;
31256 99 dowarp(1,0); //side warp
31257 99 }
31258 else
31259 {
31260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) playLevelMusic();
31261 }
31262 100 }
31263
31264 28305 void red_shift()
31265 {
31266 28305 int32_t tnum=176;
31267
31268 // set up the new palette
31269
2/2
✓ Branch 0 taken 905760 times.
✓ Branch 1 taken 28305 times.
934065 for(int32_t i=CSET(2); i < CSET(4); i++)
31270 {
31271 905760 int32_t r = (i-CSET(2)) << 1;
31272 905760 RAMpal[i+tnum].r = r;
31273 905760 RAMpal[i+tnum].g = r >> 3;
31274 905760 RAMpal[i+tnum].b = r >> 4;
31275 905760 }
31276
31277 // color scale the game screen
31278
2/2
✓ Branch 0 taken 4755240 times.
✓ Branch 1 taken 28305 times.
4783545 for(int32_t y=0; y<168; y++)
31279 {
31280
2/2
✓ Branch 0 taken 1217341440 times.
✓ Branch 1 taken 4755240 times.
1222096680 for(int32_t x=0; x<256; x++)
31281 {
31282 1217341440 int32_t c = framebuf->line[y+playing_field_offset][x];
31283
2/2
✓ Branch 0 taken 1145300341 times.
✓ Branch 1 taken 72041099 times.
1217341440 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
31284
2/2
✓ Branch 0 taken 1216474607 times.
✓ Branch 1 taken 866833 times.
1217341440 framebuf->line[y+playing_field_offset][x] = (c ? (r+tnum+CSET(2)) : 0);
31285 1217341440 }
31286 4755240 }
31287
31288 28305 refreshpal = true;
31289 28305 }
31290
31291
31292
31293 void setup_red_screen_old()
31294 {
31295 clear_bitmap(framebuf);
31296 rectfill(scrollbuf, 0, 0, 255, 167, 0);
31297
31298 if(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, tmpscr, 0, playing_field_offset, 2);
31299
31300 if(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, tmpscr, 0, playing_field_offset, 2);
31301
31302 if(lenscheck(tmpscr,0)) putscr(scrollbuf, 0, 0, tmpscr);
31303 putscrdoors(scrollbuf,0,0,tmpscr);
31304 blit(scrollbuf, framebuf, 0, 0, 0, playing_field_offset, 256, 168);
31305 do_layer(framebuf, 0, 1, tmpscr, 0, 0, 2);
31306
31307 if(!(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, tmpscr, 0, 0, 2);
31308
31309 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
31310 {
31311 do_layer(framebuf, -2, 0, tmpscr, 0, 0, 2);
31312 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
31313 {
31314 do_layer(framebuf, -2, 1, tmpscr, 0, 0, 2);
31315 do_layer(framebuf, -2, 2, tmpscr, 0, 0, 2);
31316 }
31317 }
31318
31319 if(!(msg_bg_display_buf->clip))
31320 {
31321 blit_msgstr_bg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
31322 }
31323
31324 if(!(msg_portrait_display_buf->clip))
31325 {
31326 blit_msgstr_prt(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
31327 }
31328
31329 if(!(msg_txt_display_buf->clip))
31330 {
31331 blit_msgstr_fg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
31332 }
31333
31334 if(!(pricesdisplaybuf->clip))
31335 {
31336 masked_blit(pricesdisplaybuf, framebuf,0,0,0,playing_field_offset, 256,168);
31337 }
31338
31339 //red shift
31340 // color scale the game screen
31341 for(int32_t y=0; y<168; y++)
31342 {
31343 for(int32_t x=0; x<256; x++)
31344 {
31345 int32_t c = framebuf->line[y+playing_field_offset][x];
31346 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
31347 framebuf->line[y+playing_field_offset][x] = (c ? (r+CSET(2)) : 0);
31348 }
31349 }
31350
31351 // Hero->draw(framebuf);
31352 blit(framebuf,scrollbuf, 0, playing_field_offset, 256, playing_field_offset, 256, 168);
31353
31354 clear_bitmap(framebuf);
31355
31356 if(!((tmpscr->layermap[2]==0||(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)))
31357 && tmpscr->layermap[3]==0
31358 && tmpscr->layermap[4]==0
31359 && tmpscr->layermap[5]==0
31360 && !overheadcombos(tmpscr)))
31361 {
31362 if(!(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, tmpscr, 0, 0, 2);
31363
31364 do_layer(framebuf, 0, 4, tmpscr, 0, 0, 2);
31365 do_layer(framebuf, -1, 0, tmpscr, 0, 0, 2);
31366 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
31367 {
31368 do_layer(framebuf, -1, 1, tmpscr, 0, 0, 2);
31369 do_layer(framebuf, -1, 2, tmpscr, 0, 0, 2);
31370 }
31371 do_layer(framebuf, 0, 5, tmpscr, 0, 0, 2);
31372 do_layer(framebuf, 0, 6, tmpscr, 0, 0, 2);
31373
31374 //do an AND masked blit for messages on top of layers
31375 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(pricesdisplaybuf->clip) || !(msg_portrait_display_buf->clip))
31376 {
31377 BITMAP* subbmp = create_bitmap_ex(8,256,168);
31378 clear_bitmap(subbmp);
31379 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(msg_portrait_display_buf->clip))
31380 {
31381 masked_blit(framebuf, subbmp, 0, playing_field_offset, 0, 0, 256, 168);
31382 if(!(msg_bg_display_buf->clip)) blit_msgstr_bg(subbmp, 0, 0, 0, 0, 256, 168);
31383 if(!(msg_portrait_display_buf->clip)) blit_msgstr_prt(subbmp, 0, 0, 0, 0, 256, 168);
31384 if(!(msg_txt_display_buf->clip)) blit_msgstr_fg(subbmp, 0, 0, 0, 0, 256, 168);
31385 }
31386 for(int32_t y=0; y<168; y++)
31387 {
31388 for(int32_t x=0; x<256; x++)
31389 {
31390 int32_t c1 = framebuf->line[y+playing_field_offset][x];
31391 int32_t c2 = subbmp->line[y][x];
31392 int32_t c3 = pricesdisplaybuf->clip ? 0 : pricesdisplaybuf->line[y][x];
31393
31394 if(c1 && c3)
31395 {
31396 framebuf->line[y+playing_field_offset][x] = c3;
31397 }
31398 else if(c1 && c2)
31399 {
31400 framebuf->line[y+playing_field_offset][x] = c2;
31401 }
31402 }
31403 }
31404 destroy_bitmap(subbmp);
31405 }
31406
31407 //red shift
31408 // color scale the game screen
31409 for(int32_t y=0; y<168; y++)
31410 {
31411 for(int32_t x=0; x<256; x++)
31412 {
31413 int32_t c = framebuf->line[y+playing_field_offset][x];
31414 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
31415 framebuf->line[y+playing_field_offset][x] = r+CSET(2);
31416 }
31417 }
31418 }
31419
31420 blit(framebuf,scrollbuf, 0, playing_field_offset, 0, playing_field_offset, 256, 168);
31421
31422 // set up the new palette
31423 for(int32_t i=CSET(2); i < CSET(4); i++)
31424 {
31425 int32_t r = (i-CSET(2)) << 1;
31426 RAMpal[i].r = r;
31427 RAMpal[i].g = r >> 3;
31428 RAMpal[i].b = r >> 4;
31429 }
31430
31431 refreshpal = true;
31432 }
31433
31434
31435
31436 75 void slide_in_color(int32_t color)
31437 {
31438
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 75 times.
450 for(int32_t i=1; i<16; i+=3)
31439 {
31440 375 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
31441 375 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
31442 375 RAMpal[CSET(2)+i] = NESpal(color);
31443 375 }
31444
31445 75 refreshpal=true;
31446 75 }
31447
31448
31449 272 void HeroClass::heroDeathAnimation()
31450 {
31451 272 int32_t f=0;
31452 272 int32_t deathclk=0,deathfrm=0;
31453
31454 272 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
31455
31456 272 kill_sfx(); //call before the onDeath script.
31457
31458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 if(!debug_enabled)
31459 {
31460 272 Paused=false;
31461 272 }
31462
31463 /*
31464 game->set_deaths(zc_min(game->get_deaths()+1,999));
31465 dir=down;
31466 music_stop();
31467
31468 attackclk=hclk=superman=0;
31469 scriptcoldet = true;
31470
31471 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
31472
31473
31474
31475 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
31476 quakeclk=wavy=0;
31477
31478 //in original Z1, Hero marker vanishes at death.
31479 //code in subscr.cpp, put_passive_subscr checks the following value.
31480 //color 255 is a GUI color, so quest makers shouldn't be using this value.
31481 //Also, subscreen is static after death in Z1.
31482 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
31483 QMisc.colors.hero_dot = 255;
31484 //doesn't work
31485 //scrollbuf is tampered with by draw_screen()
31486 //put_passive_subscr(scrollbuf, 256, passive_subscreen_offset, false, false);//save this and reuse it.
31487 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
31488 clear_bitmap(subscrbmp);
31489 put_passive_subscr(subscrbmp, 0, passive_subscreen_offset, false, sspUP);
31490 QMisc.colors.hero_dot = tmp_hero_dot;
31491 */
31492 272 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
31493 272 clear_bitmap(subscrbmp);
31494 //get rid off all sprites but Hero
31495 272 guys.clear();
31496 272 items.clear();
31497 272 Ewpns.clear();
31498 272 Lwpns.clear();
31499 272 chainlinks.clear();
31500 272 decorations.clear();
31501
31502 272 kill_subscr_items();
31503
31504 272 Playing = false;
31505
31506
1/2
✓ Branch 0 taken 272 times.
✗ Branch 1 not taken.
272 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
31507 272 dir=down;
31508 272 music_stop();
31509
31510 272 attackclk=hclk=superman=0;
31511 272 scriptcoldet = true;
31512
31513
2/2
✓ Branch 0 taken 8704 times.
✓ Branch 1 taken 272 times.
8976 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
31514
31515
31516
31517 272 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
31518 272 quakeclk=wavy=0;
31519
31520 //in original Z1, Hero marker vanishes at death.
31521 //code in subscr.cpp, put_passive_subscr checks the following value.
31522 //color 255 is a GUI color, so quest makers shouldn't be using this value.
31523 //Also, subscreen is static after death in Z1.
31524 272 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
31525 272 QMisc.colors.hero_dot = 255;
31526 //doesn't work
31527 //scrollbuf is tampered with by draw_screen()
31528 //put_passive_subscr(scrollbuf, 256, passive_subscreen_offset, false, false);//save this and reuse it.
31529
31530 272 put_passive_subscr(subscrbmp, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
31531 //Don't forget passive subscreen scripts!
31532
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 22 times.
272 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
31533 {
31534 22 script_drawing_commands.Clear(); //We only want draws from this script
31535
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(DMaps[currdmap].passive_sub_script != 0)
31536 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
31537
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 if (FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && DMaps[currdmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen))
31538 {
31539 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
31540 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
31541 }
31542 22 BITMAP* tmp = framebuf;
31543 22 framebuf = subscrbmp; //Hack; force draws to subscrbmp
31544 22 do_script_draws(framebuf, tmpscr, 0, playing_field_offset); //Draw the script draws
31545 22 framebuf = tmp;
31546 22 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
31547 22 }
31548 272 QMisc.colors.hero_dot = tmp_hero_dot;
31549 272 bool clearedit = false;
31550 272 do
31551 {
31552
2/2
✓ Branch 0 taken 68857 times.
✓ Branch 1 taken 25260 times.
94117 if(f<254)
31553 {
31554
2/2
✓ Branch 0 taken 59945 times.
✓ Branch 1 taken 8912 times.
68857 if(f<=32)
31555 {
31556 8912 hclk=(32-f);
31557 8912 }
31558
31559
4/4
✓ Branch 0 taken 52115 times.
✓ Branch 1 taken 16742 times.
✓ Branch 2 taken 31595 times.
✓ Branch 3 taken 20520 times.
68857 if(f>=62 && f<138)
31560 {
31561
5/5
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
✓ Branch 2 taken 1080 times.
✓ Branch 3 taken 1080 times.
✓ Branch 4 taken 1080 times.
20520 switch((f-62)%20)
31562 {
31563 case 0:
31564 1080 dir=right;
31565 1080 break;
31566
31567 case 5:
31568 1080 dir=up;
31569 1080 break;
31570
31571 case 10:
31572 1080 dir=left;
31573 1080 break;
31574
31575 case 15:
31576 1080 dir=down;
31577 1080 break;
31578 }
31579
31580 20520 herostep();
31581 20520 }
31582
31583
4/4
✓ Branch 0 taken 16475 times.
✓ Branch 1 taken 52382 times.
✓ Branch 2 taken 12400 times.
✓ Branch 3 taken 4075 times.
68857 if(f>=194 && f<208)
31584 {
31585
2/2
✓ Branch 0 taken 3805 times.
✓ Branch 1 taken 270 times.
4075 if(f==194)
31586 {
31587 270 action=dying;
31588 270 FFCore.setHeroAction(dying);
31589 270 }
31590
31591 4075 extend = 0;
31592 4075 cs = wpnsbuf[spr_death].csets&15;
31593 4075 tile = wpnsbuf[spr_death].tile;
31594
2/2
✓ Branch 0 taken 3500 times.
✓ Branch 1 taken 575 times.
4075 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
31595 {
31596 575 tile += deathfrm;
31597 575 f = 206;
31598
2/2
✓ Branch 0 taken 495 times.
✓ Branch 1 taken 80 times.
575 if(++deathclk >= wpnsbuf[spr_death].speed)
31599 {
31600 80 deathclk=0;
31601
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 20 times.
80 if(++deathfrm >= wpnsbuf[spr_death].frames)
31602 {
31603 20 f = 208;
31604 20 deathfrm = 0;
31605 20 }
31606 80 }
31607 575 }
31608
2/2
✓ Branch 0 taken 2632 times.
✓ Branch 1 taken 868 times.
3500 else if(BSZ)
31609 {
31610 2632 tile += (f-194)/3;
31611 2632 }
31612
2/2
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 248 times.
868 else if(f>=204)
31613 {
31614 248 ++tile;
31615 248 }
31616 4075 }
31617
31618
2/2
✓ Branch 0 taken 68587 times.
✓ Branch 1 taken 270 times.
68857 if(f==208)
31619 {
31620
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 266 times.
270 if ( dontdraw < 2 ) { dontdraw = 1; }
31621 270 }
31622
2/2
✓ Branch 0 taken 65047 times.
✓ Branch 1 taken 3810 times.
68857 if(get_qr(qr_FADE))
31623 {
31624
2/2
✓ Branch 0 taken 43352 times.
✓ Branch 1 taken 21695 times.
65047 if(f < 170)
31625 {
31626
2/2
✓ Branch 0 taken 28050 times.
✓ Branch 1 taken 15302 times.
43352 if(f<60)
31627 {
31628 15302 draw_screen(tmpscr);
31629 //reuse our static subscreen
31630 15302 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
31631 15302 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31632 15302 }
31633
31634
2/2
✓ Branch 0 taken 43097 times.
✓ Branch 1 taken 255 times.
43352 if(f==60)
31635 {
31636 255 red_shift();
31637 255 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
31638 255 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
31639 255 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
31640
31641
2/2
✓ Branch 0 taken 65280 times.
✓ Branch 1 taken 255 times.
65535 for(int32_t q=0; q<PAL_SIZE; q++)
31642 {
31643 65280 trans_table2.data[0][q] = q;
31644 65280 trans_table2.data[q][q] = q;
31645 65280 }
31646 255 }
31647
31648
3/4
✓ Branch 0 taken 28050 times.
✓ Branch 1 taken 15302 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28050 times.
43352 if(f>=60 && f<=169)
31649 {
31650 28050 draw_screen(tmpscr);
31651 //reuse our static subscreen
31652 28050 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31653 28050 red_shift();
31654
31655 28050 }
31656
31657
3/4
✓ Branch 0 taken 7905 times.
✓ Branch 1 taken 35447 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7905 times.
43352 if(f>=139 && f<=169)//fade from red to black
31658 {
31659 7905 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
31660 7905 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
31661 7905 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
31662 7905 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
31663
31664
2/2
✓ Branch 0 taken 2023680 times.
✓ Branch 1 taken 7905 times.
2031585 for(int32_t q=0; q<PAL_SIZE; q++)
31665 {
31666 2023680 trans_table2.data[0][q] = q;
31667 2023680 trans_table2.data[q][q] = q;
31668 2023680 }
31669
31670 7905 refreshpal=true;
31671 7905 }
31672 43352 }
31673 else //f>=170
31674 {
31675
2/2
✓ Branch 0 taken 21440 times.
✓ Branch 1 taken 255 times.
21695 if(f==170)//make Hero grayish
31676 {
31677 255 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
31678
31679
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 255 times.
4335 for(int32_t i=CSET(6); i < CSET(7); i++)
31680 {
31681 4080 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
31682 4080 RAMpal[i] = _RGB(g,g,g);
31683 4080 }
31684
31685 255 refreshpal = true;
31686 255 }
31687
31688 //draw only hero. otherwise black layers might cover him.
31689 21695 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
31690 21695 draw(framebuf);
31691 21695 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31692 }
31693 65047 }
31694 else //!qr_FADE
31695 {
31696
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==58)
31697 {
31698
2/2
✓ Branch 0 taken 1440 times.
✓ Branch 1 taken 15 times.
1455 for(int32_t i = 0; i < 96; i++)
31699 1440 tmpscr->cset[i] = 3;
31700
31701
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 15 times.
105 for(int32_t j=0; j<6; j++)
31702
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 2 times.
92 if(tmpscr->layermap[j]>0)
31703
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
31704 194 tmpscr2[j].cset[i] = 3;
31705 15 }
31706
31707
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==59)
31708 {
31709
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 15 times.
1215 for(int32_t i = 96; i < 176; i++)
31710 1200 tmpscr->cset[i] = 3;
31711
31712
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 15 times.
105 for(int32_t j=0; j<6; j++)
31713
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 2 times.
92 if(tmpscr->layermap[j]>0)
31714
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
31715 162 tmpscr2[j].cset[i] = 3;
31716 15 }
31717
31718
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==60)
31719 {
31720
2/2
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 15 times.
2655 for(int32_t i=0; i<176; i++)
31721 {
31722 2640 tmpscr->cset[i] = 2;
31723 2640 }
31724
31725
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 15 times.
105 for(int32_t j=0; j<6; j++)
31726
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 2 times.
92 if(tmpscr->layermap[j]>0)
31727
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
31728 354 tmpscr2[j].cset[i] = 2;
31729
31730
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 15 times.
90 for(int32_t i=1; i<16; i+=3)
31731 {
31732 75 RAMpal[CSET(2)+i] = NESpal(0x17);
31733 75 RAMpal[CSET(2)+i+1] = NESpal(0x16);
31734 75 RAMpal[CSET(2)+i+2] = NESpal(0x26);
31735 75 }
31736
31737 15 refreshpal=true;
31738 15 }
31739
31740
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==139)
31741 15 slide_in_color(0x06);
31742
31743
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==149)
31744 15 slide_in_color(0x07);
31745
31746
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==159)
31747 15 slide_in_color(0x0F);
31748
31749
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==169)
31750 {
31751 15 slide_in_color(0x0F);
31752 15 slide_in_color(0x0F);
31753 15 }
31754
31755
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==170)
31756 {
31757
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 15 times.
90 for(int32_t i=1; i<16; i+=3)
31758 {
31759 75 RAMpal[CSET(6)+i] = NESpal(0x10);
31760 75 RAMpal[CSET(6)+i+1] = NESpal(0x30);
31761 75 RAMpal[CSET(6)+i+2] = NESpal(0x00);
31762 75 refreshpal = true;
31763 75 }
31764 15 }
31765
31766
2/2
✓ Branch 0 taken 2535 times.
✓ Branch 1 taken 1275 times.
3810 if(f < 169)
31767 {
31768 2535 draw_screen(tmpscr);
31769 //reuse our static subscreen
31770 2535 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31771 2535 }
31772 else
31773 {
31774 //draw only hero. otherwise black layers might cover him.
31775 1275 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
31776 1275 draw(framebuf);
31777 1275 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31778 }
31779 }
31780 68857 }
31781
31782
2/2
✓ Branch 0 taken 24495 times.
✓ Branch 1 taken 765 times.
25260 else if(f<350)//draw 'GAME OVER' text
31783 {
31784
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24495 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24495 if(get_qr(qr_INSTANT_RESPAWN) && !get_qr(qr_INSTANT_CONTINUE))
31785 {
31786 Quit = qRELOAD;
31787 skipcont = 1;
31788 clear_bitmap(framebuf);
31789 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31790 }
31791
3/4
✓ Branch 0 taken 24495 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24480 times.
✓ Branch 3 taken 15 times.
24495 else if(!get_qr(qr_INSTANT_RESPAWN) && get_qr(qr_INSTANT_CONTINUE))
31792 {
31793 15 Quit = qCONT;
31794 15 skipcont = 1;
31795 15 clear_bitmap(framebuf);
31796 15 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31797 15 }
31798 else
31799 {
31800 24480 clear_info_bmp();
31801 24480 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
31802 24480 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31803 24480 textout_ex(framebuf,get_zc_font(font_zfont),"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
31804 }
31805 24495 }
31806 else
31807 {
31808 765 clear_bitmap(framebuf);
31809 }
31810
31811 //SFX... put them all here
31812
4/4
✓ Branch 0 taken 93325 times.
✓ Branch 1 taken 272 times.
✓ Branch 2 taken 270 times.
✓ Branch 3 taken 250 times.
94117 switch(f)
31813 {
31814 case 0:
31815 272 sfx(getHurtSFX(),pan(x.getInt()));
31816 272 break;
31817 //Death sound.
31818 case 60:
31819 270 sfx(WAV_SPIRAL);
31820 270 break;
31821 //Message sound.
31822 case 194:
31823 250 sfx(WAV_MSG);
31824 250 break;
31825 }
31826 //adv:
31827 94117 clear_darkroom_bitmaps();
31828 94117 advanceframe(true);
31829 94117 ++f;
31830
2/2
✓ Branch 0 taken 93845 times.
✓ Branch 1 taken 272 times.
188234 }
31831
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 93862 times.
94117 while(f<353 && !Quit);
31832
31833 272 destroy_bitmap(subscrbmp);
31834 272 action=none; FFCore.setHeroAction(none);
31835
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 268 times.
272 if ( dontdraw < 2 ) { dontdraw=0; }
31836 272 }
31837
31838
31839 17 void HeroClass::ganon_intro()
31840 {
31841 /*
31842 ************************
31843 * GANON INTRO SEQUENCE *
31844 ************************
31845 -25 DOT updates
31846 -24 HERO in
31847 0 TRIFORCE overhead - code begins at this point (f == 0)
31848 47 GANON in
31849 58 LIGHT step
31850 68 LIGHT step
31851 78 LIGHT step
31852 255 TRIFORCE out
31853 256 TRIFORCE in
31854 270 TRIFORCE out
31855 271 GANON out, HERO face up
31856 */
31857 17 loaded_guys=true;
31858 17 loaditem();
31859
31860
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 13 times.
17 if(game->lvlitems[dlevel]&liBOSS)
31861 {
31862 4 return;
31863 }
31864
31865 13 dir=down;
31866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if ( !isSideViewHero() )
31867 {
31868 13 fall = 0; //Fix midair glitch on holding triforce. -Z
31869 13 fakefall = 0;
31870 13 z = 0;
31871 13 fakez = 0;
31872 13 }
31873 13 action=landhold2; FFCore.setHeroAction(landhold2);
31874 13 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
31875 //not good, as this only returns the highest level that Hero possesses. -DD
31876 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
31877
31878
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3133 times.
✓ Branch 2 taken 3133 times.
✓ Branch 3 taken 13 times.
3146 for(int32_t f=0; f<271 && !Quit; f++)
31879 {
31880
2/2
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
3133 if(f==47)
31881 {
31882 13 music_stop();
31883 13 stop_sfx(WAV_ROAR);
31884 13 sfx(WAV_GASP);
31885 13 sfx(WAV_GANON);
31886 13 int32_t Id=0;
31887
31888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 for(int32_t i=0; i<eMAXGUYS; i++)
31889 {
31890
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 13 times.
1027 if(guysbuf[i].flags2&eneflag_ganon)
31891 {
31892 13 Id=i;
31893 13 break;
31894 }
31895 1014 }
31896
31897
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 3 times.
13 if(current_item(itype_ring))
31898 {
31899 10 addenemy(160,96,Id,0);
31900 10 }
31901 else
31902 {
31903 3 addenemy(80,32,Id,0);
31904 }
31905 13 }
31906
31907
2/2
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
3133 if(f==48)
31908 {
31909 13 lighting(true,true); // Hmm. -L
31910 13 f += 30;
31911 13 }
31912
31913 //NES Z1, the triforce vanishes for one frame in two cases
31914 //while still showing Hero's two-handed overhead sprite.
31915 //This should be a Quest Rule for NES Accuracy. -Z
31916
4/4
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 3107 times.
3133 if(f==255 || f==270)
31917 {
31918 26 holditem=-1;
31919 26 }
31920
31921
2/2
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
3133 if(f==256)
31922 {
31923 13 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
31924 13 }
31925
31926 3133 draw_screen(tmpscr);
31927 3133 advanceframe(true);
31928
31929
1/2
✓ Branch 0 taken 3133 times.
✗ Branch 1 not taken.
3133 if(rSbtn())
31930 {
31931 conveyclk=3;
31932 int32_t tmp_subscr_clk = frame;
31933 dosubscr();
31934 newscr_clk += frame - tmp_subscr_clk;
31935 }
31936
31937 3133 }
31938
31939 13 action=none; FFCore.setHeroAction(none);
31940 13 dir=up;
31941
31942
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11 times.
13 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
31943 2 jukebox(MAXMIDIS-1);
31944 else
31945 11 playLevelMusic();
31946
31947 13 currcset=DMaps[currdmap].color;
31948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (get_qr(qr_GANONINTRO) )
31949 {
31950 13 dointro();
31951 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
31952 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
31953 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
31954 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
31955 13 }
31956 //dointro(); //This is likely what causes Ganon Rooms to repeat the DMap intro.
31957 //I suppose it is to allow the user to make Gaanon rooms have their own dialogue, if they are
31958 //on a different DMap.
31959 //~ Otherwise, why is it here?! -Z
31960
31961
31962 //if ( !(DMaps[currdmap].flags&dmfALWAYSMSG) ) { dointro(); } //This is likely what causes Ganon Rooms to repeat the DMap intro.
31963 //If we try it this way: The dmap flag /always display intro string/ is probably why James had this issue.
31964
31965 //The only fix that I can think of, off the top of me head, is either a QR or a Screen Flag to disable the intro text.
31966 //Users who use that dmap rule should put ganons room on its own DMap! -Z
31967 13 cont_sfx(WAV_ROAR);
31968 17 }
31969
31970 11 void HeroClass::win_game()
31971 {
31972
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 replay_step_comment("win_game");
31973 11 Playing=Paused=false;
31974 11 action=won; FFCore.setHeroAction(won);
31975 11 Quit=qWON;
31976 11 hclk=0;
31977 11 x = 136;
31978
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 y = (isdungeon() && currscr<128) ? 75 : 73;
31979 11 z = fakez = fall = fakefall = spins = 0;
31980 11 dir=left;
31981 11 }
31982
31983 39431 void HeroClass::reset_swordcharge()
31984 {
31985 39431 charging=spins=tapping=0;
31986 39431 }
31987
31988 137942 void HeroClass::reset_hookshot()
31989 {
31990
10/12
✓ Branch 0 taken 89016 times.
✓ Branch 1 taken 48926 times.
✓ Branch 2 taken 89002 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 88921 times.
✓ Branch 5 taken 81 times.
✓ Branch 6 taken 88914 times.
✓ Branch 7 taken 7 times.
✓ Branch 8 taken 88914 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 88914 times.
137942 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
31991 {
31992 88914 action=none; FFCore.setHeroAction(none);
31993 88914 }
31994
31995 137942 hookshot_frozen=false;
31996 137942 hookshot_used=false;
31997 137942 pull_hero=false;
31998 137942 hs_fix=false;
31999 137942 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
32000 137942 switch_hooked = false;
32001
2/2
✓ Branch 0 taken 137937 times.
✓ Branch 1 taken 5 times.
137942 if(switching_object)
32002 5 switching_object->switch_hooked = false;
32003 137942 switching_object = NULL;
32004 137942 hooked_combopos = -1;
32005 137942 switchhook_cost_item = -1;
32006 137942 hooked_layerbits = 0;
32007
2/2
✓ Branch 0 taken 965594 times.
✓ Branch 1 taken 137942 times.
1103536 for(auto q = 0; q < 7; ++q)
32008 965594 hooked_undercombos[q] = -1;
32009 137942 Lwpns.del(Lwpns.idFirst(wHSHandle));
32010 137942 Lwpns.del(Lwpns.idFirst(wHookshot));
32011 137942 chainlinks.clear();
32012
2/2
✓ Branch 0 taken 33496 times.
✓ Branch 1 taken 104446 times.
137942 int32_t index=directWpn>-1 ? directWpn : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
32013 137942 hs_switcher = false;
32014
32015
2/2
✓ Branch 0 taken 94428 times.
✓ Branch 1 taken 43514 times.
137942 if(index>=0)
32016 {
32017 43514 stop_sfx(itemsbuf[index].usesound);
32018 43514 }
32019
32020 137942 hs_xdist=0;
32021 137942 hs_ydist=0;
32022 137942 }
32023
32024
32025 16989497 bool HeroClass::can_deploy_ladder()
32026 {
32027
2/2
✓ Branch 0 taken 7099327 times.
✓ Branch 1 taken 9890170 times.
29961926 bool ladderallowed = ((!get_qr(qr_LADDERANYWHERE) && (tmpscr->flags&fLADDER)) || isdungeon()
32028
4/4
✓ Branch 0 taken 3926911 times.
✓ Branch 1 taken 12972429 times.
✓ Branch 2 taken 4778180 times.
✓ Branch 3 taken 8194249 times.
9890170 || (get_qr(qr_LADDERANYWHERE) && !(tmpscr->flags&fLADDER)));
32029
9/10
✓ Branch 0 taken 6585276 times.
✓ Branch 1 taken 17413391 times.
✓ Branch 2 taken 2925241 times.
✓ Branch 3 taken 3660035 times.
✓ Branch 4 taken 2924989 times.
✓ Branch 5 taken 252 times.
✓ Branch 6 taken 2924284 times.
✓ Branch 7 taken 705 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2924284 times.
26922951 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
32030
2/2
✓ Branch 0 taken 2903473 times.
✓ Branch 1 taken 20811 times.
2924284 (!isSideViewHero() || on_sideview_solid_oldpos(this)));
32031 }
32032
32033 9609469 void HeroClass::reset_ladder()
32034 {
32035 9609469 ladderx=laddery=0;
32036 9609469 }
32037
32038 bool is_conveyor(int32_t type);
32039 int32_t get_conveyor(int32_t x, int32_t y);
32040
32041 14162639 void HeroClass::check_conveyor()
32042 {
32043 14162639 ++newconveyorclk;
32044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14162639 times.
14162639 if (newconveyorclk < 0) newconveyorclk = 0;
32045
32046
2/2
✓ Branch 0 taken 14159422 times.
✓ Branch 1 taken 3217 times.
14162639 if (is_conveyor_stunned)
32047 3217 --is_conveyor_stunned;
32048
32049
16/18
✓ Branch 0 taken 14158744 times.
✓ Branch 1 taken 3895 times.
✓ Branch 2 taken 14158744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14152760 times.
✓ Branch 5 taken 5984 times.
✓ Branch 6 taken 14152760 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14152504 times.
✓ Branch 9 taken 256 times.
✓ Branch 10 taken 14145209 times.
✓ Branch 11 taken 7295 times.
✓ Branch 12 taken 14128026 times.
✓ Branch 13 taken 17183 times.
✓ Branch 14 taken 14109390 times.
✓ Branch 15 taken 18636 times.
✓ Branch 16 taken 14109670 times.
✓ Branch 17 taken 18356 times.
14162639 if(action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)))
32050 {
32051 52969 is_conveyor_stunned = 0;
32052 52969 return;
32053 }
32054
32055 14109670 WalkflagInfo info;
32056 int32_t xoff,yoff;
32057 14109670 zfix deltax(0), deltay(0);
32058 14109670 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
32059
2/2
✓ Branch 0 taken 19053 times.
✓ Branch 1 taken 14090617 times.
14109670 if(cmbid < 0)
32060 {
32061
2/2
✓ Branch 0 taken 9415005 times.
✓ Branch 1 taken 4675612 times.
14090617 if (conveyclk <= 0)
32062 {
32063 4675612 is_on_conveyor = false;
32064 4675612 conv_forcedir = -1;
32065 4675612 }
32066 14090617 return;
32067 }
32068 19053 newcombo const* cmb = &combobuf[cmbid];
32069 19053 auto pos = COMBOPOS(x+7,y+(bigHitbox?8:12));
32070 19053 bool custom_spd = (cmb->usrflags&cflag2);
32071
3/4
✓ Branch 0 taken 15782 times.
✓ Branch 1 taken 3271 times.
✓ Branch 2 taken 15782 times.
✗ Branch 3 not taken.
19053 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
32072 {
32073 19053 int32_t ctype=cmb->type;
32074
3/4
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 15782 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3271 times.
19053 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
32075
3/4
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 15782 times.
✓ Branch 2 taken 3271 times.
✗ Branch 3 not taken.
19053 if(custom_spd && (newconveyorclk % rate)) return;
32076
3/4
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 15782 times.
✓ Branch 2 taken 3271 times.
✗ Branch 3 not taken.
19053 if((cmb->usrflags&cflag5) && HasHeavyBoots())
32077 return;
32078 19053 is_on_conveyor=false;
32079 19053 conv_forcedir=-1;
32080 19053 is_conveyor_stunned=0;
32081
32082 19053 deltax=combo_class_buf[ctype].conveyor_x_speed;
32083 19053 deltay=combo_class_buf[ctype].conveyor_y_speed;
32084
32085
3/4
✓ Branch 0 taken 19053 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15782 times.
✓ Branch 3 taken 3271 times.
19053 if (is_conveyor(ctype) && custom_spd)
32086 {
32087 3271 deltax = zslongToFix(cmb->attributes[0]);
32088 3271 deltay = zslongToFix(cmb->attributes[1]);
32089 3271 }
32090
32091
3/8
✓ Branch 0 taken 8708 times.
✓ Branch 1 taken 10345 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8708 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
19053 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(this)))
32092 {
32093 cmbid = MAPCOMBO(x+8,y+16);
32094 cmb = &combobuf[cmbid];
32095 custom_spd = cmb->usrflags&cflag2;
32096 ctype=(cmb->type);
32097 rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
32098 deltax=combo_class_buf[ctype].conveyor_x_speed;
32099 deltay=combo_class_buf[ctype].conveyor_y_speed;
32100 if ((deltax != 0 || deltay != 0) && custom_spd)
32101 {
32102 deltax = zslongToFix(cmb->attributes[0]);
32103 deltay = zslongToFix(cmb->attributes[1]);
32104 }
32105 }
32106
32107
3/4
✓ Branch 0 taken 8708 times.
✓ Branch 1 taken 10345 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8708 times.
19053 if(deltax!=0||deltay!=0)
32108 {
32109 19053 is_on_conveyor=true;
32110 19053 }
32111 else return;
32112
32113
1/2
✓ Branch 0 taken 19053 times.
✗ Branch 1 not taken.
19053 bool forcewalk = (cmb->usrflags&cflag6) && get_qr(qr_NEW_HERO_MOVEMENT2);
32114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19053 times.
19053 if(forcewalk)
32115 {
32116 is_conveyor_stunned = rate;
32117 if((cmb->usrflags&cflag3) && !spins)
32118 {
32119 if(abs(deltax) > abs(deltay))
32120 conv_forcedir = dir = (deltax > 0) ? right : left;
32121 else conv_forcedir = dir = (deltay > 0) ? down : up;
32122 }
32123 convey_forcex = deltax;
32124 convey_forcey = deltay;
32125 }
32126 else
32127 {
32128 19053 bool movedx = false, movedy = false;
32129
2/2
✓ Branch 0 taken 15782 times.
✓ Branch 1 taken 3271 times.
19053 if(cmb->usrflags&cflag4) //Smart corners
32130 {
32131
2/2
✓ Branch 0 taken 1095 times.
✓ Branch 1 taken 2176 times.
3271 if(deltay<0)
32132 {
32133 1095 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
32134 1095 execute(info);
32135
32136
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 1044 times.
1095 if(!info.isUnwalkable())
32137 {
32138 1044 movedy = true;
32139 1044 zfix step(0);
32140
32141
5/12
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 900 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 144 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1044 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
32142 {
32143 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
32144 {
32145 yoff=int32_t(y-step)&7;
32146
32147 if(!yoff) break;
32148
32149 step++;
32150 }
32151 }
32152 else
32153 {
32154 1044 step=abs(deltay);
32155 }
32156
32157 1044 y=y-step;
32158 1044 hs_starty-=step.getInt();
32159
32160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1044 times.
1044 for(int32_t j=0; j<chainlinks.Count(); j++)
32161 {
32162 chainlinks.spr(j)->y-=step;
32163 }
32164
32165
1/2
✓ Branch 0 taken 1044 times.
✗ Branch 1 not taken.
1044 if(Lwpns.idFirst(wHookshot)>-1)
32166 {
32167 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
32168 }
32169
32170
1/2
✓ Branch 0 taken 1044 times.
✗ Branch 1 not taken.
1044 if(Lwpns.idFirst(wHSHandle)>-1)
32171 {
32172 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
32173 }
32174 1044 }
32175 1095 }
32176
2/2
✓ Branch 0 taken 1769 times.
✓ Branch 1 taken 407 times.
2176 else if(deltay>0)
32177 {
32178 407 info = walkflag(x,y+15+2,2,down);
32179 407 execute(info);
32180
32181
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 402 times.
407 if(!info.isUnwalkable())
32182 {
32183 402 movedy = true;
32184 402 zfix step(0);
32185
32186
7/12
✓ Branch 0 taken 311 times.
✓ Branch 1 taken 91 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 311 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 82 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
402 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
32187 {
32188 while(step<abs(deltay))
32189 {
32190 yoff=int32_t(y+step)&7;
32191
32192 if(!yoff) break;
32193
32194 step++;
32195 }
32196 }
32197 else
32198 {
32199 402 step=abs(deltay);
32200 }
32201
32202 402 y=y+step;
32203 402 hs_starty+=step.getInt();
32204
32205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
402 for(int32_t j=0; j<chainlinks.Count(); j++)
32206 {
32207 chainlinks.spr(j)->y+=step;
32208 }
32209
32210
1/2
✓ Branch 0 taken 402 times.
✗ Branch 1 not taken.
402 if(Lwpns.idFirst(wHookshot)>-1)
32211 {
32212 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
32213 }
32214
32215
1/2
✓ Branch 0 taken 402 times.
✗ Branch 1 not taken.
402 if(Lwpns.idFirst(wHSHandle)>-1)
32216 {
32217 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
32218 }
32219 402 }
32220 407 }
32221
32222
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 2775 times.
3271 if(deltax<0)
32223 {
32224 496 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
32225 496 execute(info);
32226
32227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496 times.
496 if(!info.isUnwalkable())
32228 {
32229 496 movedx = true;
32230 496 zfix step(0);
32231
32232
7/12
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 486 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
496 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
32233 {
32234 while(step<abs(deltax))
32235 {
32236 xoff=int32_t(x-step)&7;
32237
32238 if(!xoff) break;
32239
32240 step++;
32241 }
32242 }
32243 else
32244 {
32245 496 step=abs(deltax);
32246 }
32247
32248 496 x=x-step;
32249 496 hs_startx-=step.getInt();
32250
32251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496 times.
496 for(int32_t j=0; j<chainlinks.Count(); j++)
32252 {
32253 chainlinks.spr(j)->x-=step;
32254 }
32255
32256
1/2
✓ Branch 0 taken 496 times.
✗ Branch 1 not taken.
496 if(Lwpns.idFirst(wHookshot)>-1)
32257 {
32258 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
32259 }
32260
32261
1/2
✓ Branch 0 taken 496 times.
✗ Branch 1 not taken.
496 if(Lwpns.idFirst(wHSHandle)>-1)
32262 {
32263 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
32264 }
32265 496 }
32266 496 }
32267
2/2
✓ Branch 0 taken 1502 times.
✓ Branch 1 taken 1273 times.
2775 else if(deltax>0)
32268 {
32269 1273 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
32270 1273 execute(info);
32271
32272
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1259 times.
1273 if(!info.isUnwalkable())
32273 {
32274 1259 movedx = true;
32275 1259 zfix step(0);
32276
32277
7/12
✓ Branch 0 taken 1093 times.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 181 times.
✓ Branch 3 taken 1078 times.
✓ Branch 4 taken 134 times.
✓ Branch 5 taken 47 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 134 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1259 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
32278 {
32279 while(step<abs(deltax))
32280 {
32281 xoff=int32_t(x+step)&7;
32282
32283 if(!xoff) break;
32284
32285 step++;
32286 }
32287 }
32288 else
32289 {
32290 1259 step=abs(deltax);
32291 }
32292
32293 1259 x=x+step;
32294 1259 hs_startx+=step.getInt();
32295
32296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1259 times.
1259 for(int32_t j=0; j<chainlinks.Count(); j++)
32297 {
32298 chainlinks.spr(j)->x+=step;
32299 }
32300
32301
1/2
✓ Branch 0 taken 1259 times.
✗ Branch 1 not taken.
1259 if(Lwpns.idFirst(wHookshot)>-1)
32302 {
32303 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
32304 }
32305
32306
1/2
✓ Branch 0 taken 1259 times.
✗ Branch 1 not taken.
1259 if(Lwpns.idFirst(wHSHandle)>-1)
32307 {
32308 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
32309 }
32310 1259 }
32311 1273 }
32312
5/6
✓ Branch 0 taken 1769 times.
✓ Branch 1 taken 1502 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 1755 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
3271 if(deltax && !movedx && !deltay)
32313 {
32314 14 zfix oy = y;
32315 14 y = COMBOY(pos);
32316 14 bool validpush = scr_canmove(deltax, 0, false, false);
32317
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
28 zfix ny = handle_movestate_zfix([&]()
32318 {
32319 14 movexy(deltax,0,false,false,true,true);
32320 14 return y;
32321 });
32322 14 y = oy;
32323
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if (validpush || ny != COMBOY(pos))
32324 {
32325
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (y <= ny-1)
32326 {
32327 14 setYfix(y+1);
32328 14 }
32329 else if (y >= ny+1)
32330 {
32331 setYfix(y-1);
32332 }
32333 else
32334 {
32335 setYfix(ny);
32336 }
32337 14 }
32338 14 }
32339
5/6
✓ Branch 0 taken 1502 times.
✓ Branch 1 taken 1769 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 1446 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
3271 if(deltay && !movedy && !deltax)
32340 {
32341 56 zfix ox = x;
32342 56 x = COMBOX(pos);
32343 56 bool validpush = scr_canmove(0, deltay, false, false);
32344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
112 zfix nx = handle_movestate_zfix([&]()
32345 {
32346 56 movexy(0,deltay,false,false,true,true);
32347 56 return x;
32348 });
32349 56 x = ox;
32350
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
56 if (validpush || nx != COMBOX(pos))
32351 {
32352
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 3 times.
56 if (x <= nx-1)
32353 {
32354 53 setXfix(x+1);
32355 53 }
32356
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if (x >= nx+1)
32357 {
32358 setXfix(x-1);
32359 }
32360 else
32361 {
32362 3 setXfix(nx);
32363 }
32364 56 }
32365 56 }
32366 3271 }
32367
2/2
✓ Branch 0 taken 1446 times.
✓ Branch 1 taken 17607 times.
19053 if(!movedy)
32368 {
32369
2/2
✓ Branch 0 taken 2764 times.
✓ Branch 1 taken 14843 times.
17607 if(deltay<0)
32370 {
32371 2764 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
32372 2764 execute(info);
32373
32374
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 2517 times.
2764 if(!info.isUnwalkable())
32375 {
32376 2517 movedy = true;
32377 2517 zfix step(0);
32378
32379
10/12
✓ Branch 0 taken 1942 times.
✓ Branch 1 taken 575 times.
✓ Branch 2 taken 703 times.
✓ Branch 3 taken 1814 times.
✓ Branch 4 taken 218 times.
✓ Branch 5 taken 485 times.
✓ Branch 6 taken 195 times.
✓ Branch 7 taken 23 times.
✓ Branch 8 taken 195 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 195 times.
2517 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
32380 {
32381
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 373 times.
530 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
32382 {
32383 373 yoff=int32_t(y-step)&7;
32384
32385
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 38 times.
373 if(!yoff) break;
32386
32387 335 step++;
32388 }
32389 195 }
32390 else
32391 {
32392 2322 step=abs(deltay);
32393 }
32394
32395 2517 y=y-step;
32396 2517 hs_starty-=step.getInt();
32397
32398
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 2517 times.
2536 for(int32_t j=0; j<chainlinks.Count(); j++)
32399 {
32400 19 chainlinks.spr(j)->y-=step;
32401 19 }
32402
32403
2/2
✓ Branch 0 taken 2498 times.
✓ Branch 1 taken 19 times.
2517 if(Lwpns.idFirst(wHookshot)>-1)
32404 {
32405 19 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
32406 19 }
32407
32408
2/2
✓ Branch 0 taken 2498 times.
✓ Branch 1 taken 19 times.
2517 if(Lwpns.idFirst(wHSHandle)>-1)
32409 {
32410 19 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
32411 19 }
32412 2517 }
32413 247 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
32414 2764 }
32415
2/2
✓ Branch 0 taken 10345 times.
✓ Branch 1 taken 4498 times.
14843 else if(deltay>0)
32416 {
32417 4498 info = walkflag(x,y+15+2,2,down);
32418 4498 execute(info);
32419
32420
2/2
✓ Branch 0 taken 897 times.
✓ Branch 1 taken 3601 times.
4498 if(!info.isUnwalkable())
32421 {
32422 3601 movedy = true;
32423 3601 zfix step(0);
32424
32425
10/12
✓ Branch 0 taken 2879 times.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 956 times.
✓ Branch 3 taken 2645 times.
✓ Branch 4 taken 444 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 388 times.
✓ Branch 7 taken 56 times.
✓ Branch 8 taken 388 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 388 times.
3601 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
32426 {
32427
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 646 times.
881 while(step<abs(deltay))
32428 {
32429 646 yoff=int32_t(y+step)&7;
32430
32431
2/2
✓ Branch 0 taken 493 times.
✓ Branch 1 taken 153 times.
646 if(!yoff) break;
32432
32433 493 step++;
32434 }
32435 388 }
32436 else
32437 {
32438 3213 step=abs(deltay);
32439 }
32440
32441 3601 y=y+step;
32442 3601 hs_starty+=step.getInt();
32443
32444
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3601 times.
3614 for(int32_t j=0; j<chainlinks.Count(); j++)
32445 {
32446 13 chainlinks.spr(j)->y+=step;
32447 13 }
32448
32449
2/2
✓ Branch 0 taken 3562 times.
✓ Branch 1 taken 39 times.
3601 if(Lwpns.idFirst(wHookshot)>-1)
32450 {
32451 39 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
32452 39 }
32453
32454
2/2
✓ Branch 0 taken 3562 times.
✓ Branch 1 taken 39 times.
3601 if(Lwpns.idFirst(wHSHandle)>-1)
32455 {
32456 39 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
32457 39 }
32458 3601 }
32459 897 else checkdamagecombos(x,y+15);
32460 4498 }
32461 17607 }
32462
2/2
✓ Branch 0 taken 1755 times.
✓ Branch 1 taken 17298 times.
19053 if(!movedx)
32463 {
32464
2/2
✓ Branch 0 taken 5381 times.
✓ Branch 1 taken 11917 times.
17298 if(deltax<0)
32465 {
32466 5381 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
32467 5381 execute(info);
32468
32469
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 5104 times.
5381 if(!info.isUnwalkable())
32470 {
32471 5104 movedx = true;
32472 5104 zfix step(0);
32473
32474
10/12
✓ Branch 0 taken 4579 times.
✓ Branch 1 taken 525 times.
✓ Branch 2 taken 689 times.
✓ Branch 3 taken 4415 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 372 times.
✓ Branch 6 taken 244 times.
✓ Branch 7 taken 73 times.
✓ Branch 8 taken 244 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 244 times.
5104 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
32475 {
32476
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 456 times.
635 while(step<abs(deltax))
32477 {
32478 456 xoff=int32_t(x-step)&7;
32479
32480
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 65 times.
456 if(!xoff) break;
32481
32482 391 step++;
32483 }
32484 244 }
32485 else
32486 {
32487 4860 step=abs(deltax);
32488 }
32489
32490 5104 x=x-step;
32491 5104 hs_startx-=step.getInt();
32492
32493
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 5104 times.
5146 for(int32_t j=0; j<chainlinks.Count(); j++)
32494 {
32495 42 chainlinks.spr(j)->x-=step;
32496 42 }
32497
32498
2/2
✓ Branch 0 taken 5053 times.
✓ Branch 1 taken 51 times.
5104 if(Lwpns.idFirst(wHookshot)>-1)
32499 {
32500 51 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
32501 51 }
32502
32503
2/2
✓ Branch 0 taken 5053 times.
✓ Branch 1 taken 51 times.
5104 if(Lwpns.idFirst(wHSHandle)>-1)
32504 {
32505 51 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
32506 51 }
32507 5104 }
32508 277 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
32509 5381 }
32510
2/2
✓ Branch 0 taken 8708 times.
✓ Branch 1 taken 3209 times.
11917 else if(deltax>0)
32511 {
32512 3209 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
32513 3209 execute(info);
32514
32515
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 3127 times.
3209 if(!info.isUnwalkable())
32516 {
32517 3127 movedx = true;
32518 3127 zfix step(0);
32519
32520
10/12
✓ Branch 0 taken 2627 times.
✓ Branch 1 taken 500 times.
✓ Branch 2 taken 510 times.
✓ Branch 3 taken 2617 times.
✓ Branch 4 taken 309 times.
✓ Branch 5 taken 201 times.
✓ Branch 6 taken 203 times.
✓ Branch 7 taken 106 times.
✓ Branch 8 taken 203 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 203 times.
3127 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
32521 {
32522
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 341 times.
460 while(step<abs(deltax))
32523 {
32524 341 xoff=int32_t(x+step)&7;
32525
32526
2/2
✓ Branch 0 taken 257 times.
✓ Branch 1 taken 84 times.
341 if(!xoff) break;
32527
32528 257 step++;
32529 }
32530 203 }
32531 else
32532 {
32533 2924 step=abs(deltax);
32534 }
32535
32536 3127 x=x+step;
32537 3127 hs_startx+=step.getInt();
32538
32539
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 3127 times.
3148 for(int32_t j=0; j<chainlinks.Count(); j++)
32540 {
32541 21 chainlinks.spr(j)->x+=step;
32542 21 }
32543
32544
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 23 times.
3127 if(Lwpns.idFirst(wHookshot)>-1)
32545 {
32546 23 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
32547 23 }
32548
32549
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 23 times.
3127 if(Lwpns.idFirst(wHSHandle)>-1)
32550 {
32551 23 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
32552 23 }
32553 3127 }
32554 82 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
32555 3209 }
32556 17298 }
32557
4/4
✓ Branch 0 taken 9067 times.
✓ Branch 1 taken 9986 times.
✓ Branch 2 taken 7564 times.
✓ Branch 3 taken 1503 times.
19053 if(movedx || movedy)
32558 {
32559
2/2
✓ Branch 0 taken 14333 times.
✓ Branch 1 taken 3217 times.
17550 if(cmb->usrflags&cflag1)
32560 3217 is_conveyor_stunned = rate;
32561
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17550 if((cmb->usrflags&cflag3) && !spins)
32562 {
32563 if(abs(deltax) > abs(deltay))
32564 conv_forcedir = dir = (deltax > 0) ? right : left;
32565 else conv_forcedir = dir = (deltay > 0) ? down : up;
32566 }
32567 17550 }
32568 }
32569 19053 }
32570 14162639 }
32571
32572 void HeroClass::setDivineProtectionShieldClk(int32_t newclk)
32573 {
32574 DivineProtectionShieldClk=newclk;
32575
32576 if(decorations.idCount(dDIVINEPROTECTIONSHIELD)==0)
32577 {
32578 decoration *dec;
32579 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
32580 decorations.spr(decorations.Count()-1)->misc=0;
32581 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
32582 dec=(decoration *)decorations.spr(decorations.Count()-1);
32583 decorations.spr(decorations.Count()-1)->misc=1;
32584 }
32585 }
32586
32587 35474 int32_t HeroClass::getDivineProtectionShieldClk()
32588 {
32589 35474 return DivineProtectionShieldClk;
32590 }
32591
32592 21 int32_t HeroClass::getHoverClk()
32593 {
32594 21 return hoverclk;
32595 }
32596
32597 25667501 int32_t HeroClass::getHoldClk()
32598 {
32599 25667501 return holdclk;
32600 }
32601
32602 8270860 int32_t HeroClass::getLastLensID(){
32603 8270860 return last_lens_id;
32604 }
32605
32606 209 void HeroClass::setLastLensID(int32_t p_item){
32607 209 last_lens_id = p_item;
32608 209 }
32609
32610 118539668 bool HeroClass::getOnSideviewLadder()
32611 {
32612 118539668 return on_sideview_ladder;
32613 }
32614
32615 394 void HeroClass::setOnSideviewLadder(bool val)
32616 {
32617
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if(val)
32618 {
32619 fall = fakefall = hoverclk = jumping = 0;
32620 hoverflags = 0;
32621 inair = false;
32622 }
32623 394 on_sideview_ladder = val;
32624 394 }
32625
32626 4638567 bool HeroClass::canSideviewLadder(bool down)
32627 {
32628
2/2
✓ Branch 0 taken 4604658 times.
✓ Branch 1 taken 33909 times.
4638567 if(!isSideViewHero()) return false;
32629
2/2
✓ Branch 0 taken 20703 times.
✓ Branch 1 taken 13206 times.
33909 if(jumping < 0) return false;
32630
2/2
✓ Branch 0 taken 12184 times.
✓ Branch 1 taken 8519 times.
20703 if (down)
32631 {
32632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8519 times.
8519 if (check_new_slope(x, y + 0.0001_zf, 16, 16, old_x, old_y, true))
32633 {
32634 return false;
32635 }
32636 8519 }
32637
3/4
✓ Branch 0 taken 8519 times.
✓ Branch 1 taken 12184 times.
✓ Branch 2 taken 8519 times.
✗ Branch 3 not taken.
20703 if(down && get_qr(qr_DOWN_DOESNT_GRAB_LADDERS))
32638 {
32639 bool onSolid = on_sideview_solid_oldpos(this,true);
32640 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
32641 }
32642 //Are you presently able to climb a sideview ladder?
32643 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
32644 //y+0 checks your top-half for large hitbox; y+8 for small
32645 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
32646 //y+16 check is for going down onto a ladder you are standing on.
32647
1/2
✓ Branch 0 taken 20703 times.
✗ Branch 1 not taken.
41406 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
32648
2/4
✓ Branch 0 taken 20703 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20703 times.
✗ Branch 3 not taken.
20703 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
32649
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20703 times.
✓ Branch 2 taken 12184 times.
✓ Branch 3 taken 8519 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8519 times.
29222 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
32650 4638567 }
32651
32652 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
32653 {
32654 if(!isSideViewHero()) return false;
32655 if(jumping < 0) return false;
32656 if(down && get_qr(qr_DOWN_DOESNT_GRAB_LADDERS))
32657 {
32658 bool onSolid = on_sideview_solid_oldpos(this,true);
32659 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
32660 }
32661 //Are you presently able to climb a sideview ladder?
32662 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
32663 //y+0 checks your top-half for large hitbox; y+8 for small
32664 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
32665 //y+16 check is for going down onto a ladder you are standing on.
32666 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
32667 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
32668 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
32669 }
32670
32671 9881765 void HeroClass::execute(HeroClass::WalkflagInfo info)
32672 {
32673 9881765 int32_t flags = info.getFlags();
32674
32675
2/2
✓ Branch 0 taken 1770 times.
✓ Branch 1 taken 9879995 times.
9881765 if(flags & WalkflagInfo::CLEARILSWIM)
32676 1770 ilswim =false;
32677
2/2
✓ Branch 0 taken 9876655 times.
✓ Branch 1 taken 3340 times.
9879995 else if(flags & WalkflagInfo::SETILSWIM)
32678 3340 ilswim = true;
32679
32680
1/2
✓ Branch 0 taken 9881765 times.
✗ Branch 1 not taken.
9881765 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
32681 {
32682 charging = 0;
32683 attackclk = 0;
32684 }
32685
32686
1/2
✓ Branch 0 taken 9881765 times.
✗ Branch 1 not taken.
9881765 if(flags & WalkflagInfo::SETDIR)
32687 {
32688 dir = info.getDir();
32689 }
32690
32691
2/2
✓ Branch 0 taken 9880477 times.
✓ Branch 1 taken 1288 times.
9881765 if(flags & WalkflagInfo::SETHOPCLK)
32692 {
32693 1288 hopclk = info.getHopClk();
32694 1288 }
32695
32696
2/2
✓ Branch 0 taken 9880321 times.
✓ Branch 1 taken 1444 times.
9881765 if(flags & WalkflagInfo::SETHOPDIR)
32697 {
32698 1444 hopdir = info.getHopDir();
32699 1444 }
32700
32701 9881765 }
32702
32703 17657249 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
32704 {
32705 17657249 HeroClass::WalkflagInfo ret;
32706 17657249 ret.newhopclk = newhopclk;
32707 17657249 ret.newdir = newdir;
32708
2/2
✓ Branch 0 taken 14665159 times.
✓ Branch 1 taken 2992090 times.
17657249 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
32709
32710 17657249 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
32711 17657249 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
32712 17657249 ret.flags = flags1 | flags2;
32713 17657249 return ret;
32714 }
32715
32716 211574 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
32717 {
32718 211574 HeroClass::WalkflagInfo ret;
32719 211574 ret.newhopclk = newhopclk;
32720 211574 ret.newdir = newdir;
32721
1/2
✓ Branch 0 taken 211574 times.
✗ Branch 1 not taken.
211574 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
32722
32723 211574 ret.flags = flags & other.flags;
32724 211574 return ret;
32725 }
32726
32727 211574 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
32728 {
32729 211574 HeroClass::WalkflagInfo ret;
32730 211574 ret.newhopclk = newhopclk;
32731 211574 ret.newdir = newdir;
32732 211574 ret.newhopdir = newhopdir;
32733
32734 211574 ret.flags = flags ^ UNWALKABLE;
32735 211574 return ret;
32736 }
32737
32738 void HeroClass::explode(int32_t type)
32739 {
32740 static int32_t tempx, tempy;
32741 static byte herotilebuf[256];
32742 int32_t ltile=0;
32743 int32_t lflip=0;
32744 bool shieldModify=true;
32745 unpack_tile(newtilebuf, tile, flip, true);
32746 memcpy(herotilebuf, unpackbuf, 256);
32747 tempx=Hero.getX();
32748 tempy=Hero.getY();
32749 for(int32_t i=0; i<16; ++i)
32750 {
32751 for(int32_t j=0; j<16; ++j)
32752 {
32753 if(herotilebuf[i*16+j])
32754 {
32755 if(type==0) // Twilight
32756 {
32757 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 0, 0, (zc_oldrand()%8)+i*4));
32758 int32_t k=particles.Count()-1;
32759 particle *p = (particles.at(k));
32760 p->step=3;
32761 }
32762 else if(type ==1) // Sands of Hours
32763 {
32764 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 1, 2, (zc_oldrand()%16)+i*2));
32765 int32_t k=particles.Count()-1;
32766 particle *p = (particles.at(k));
32767 p->step=4;
32768
32769 if(zc_oldrand()%10 < 2)
32770 {
32771 p->color=1;
32772 p->cset=0;
32773 }
32774 }
32775 else
32776 {
32777 particles.add(new pDivineEscapeDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 6, herotilebuf[i*16+j], zc_oldrand()%96));
32778
32779 int32_t k=particles.Count()-1;
32780 particle *p = (particles.at(k));
32781 p->angular=true;
32782 p->angle=zc_oldrand();
32783 p->step=(((double)j)/8);
32784 p->yofs=Hero.getYOfs();
32785 }
32786 }
32787 }
32788 }
32789 }
32790
32791 2224 void HeroClass::SetSwim()
32792 {
32793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2224 times.
2224 if (CanSideSwim())
32794 {
32795 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
32796 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
32797 if (get_qr(qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
32798 }
32799 2224 else {action=swimming; FFCore.setHeroAction(swimming);}
32800 2224 }
32801
32802 122870 void HeroClass::SetAttack()
32803 {
32804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 122870 times.
122870 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
32805 122870 else {action=attacking; FFCore.setHeroAction(attacking);}
32806 122870 }
32807
32808 134747344 bool HeroClass::IsSideSwim()
32809 {
32810
6/12
✓ Branch 0 taken 134747344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 134747344 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 134747344 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 134747344 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 134747344 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 134747344 times.
134747344 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
32811 }
32812
32813 2774095 bool HeroClass::CanSideSwim()
32814 {
32815
1/2
✓ Branch 0 taken 2774095 times.
✗ Branch 1 not taken.
2774095 return (isSideViewHero() && get_qr(qr_SIDESWIM));
32816 }
32817
32818 12779313 int32_t HeroClass::getTileModifier()
32819 {
32820 12779313 return item_tile_mod() + bunny_tile_mod();
32821 }
32822 void HeroClass::setImmortal(int32_t nimmortal)
32823 {
32824 immortal = nimmortal;
32825 }
32826 void HeroClass::kill(bool bypassFairy)
32827 {
32828 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
32829 }
32830 44167350 bool HeroClass::sideview_mode() const
32831 {
32832
3/4
✓ Branch 0 taken 773475 times.
✓ Branch 1 taken 43393875 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 773475 times.
44167350 return isSideViewHero() && (moveflags & FLAG_OBEYS_GRAV) && !toogam;
32833 }
32834 18082 bool HeroClass::is_unpushable() const
32835 {
32836 18082 return toogam;
32837 }
32838